From 643ed6c86a385bf180a8eeddf5ebdf1a7624dfa5 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Tue, 24 Nov 2009 14:27:17 +0100 Subject: move roles to files --- lib/MooseX/Net/API/Role/Deserialize.pm | 21 +++++++++++++++++++++ lib/MooseX/Net/API/Role/Serialize.pm | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 lib/MooseX/Net/API/Role/Deserialize.pm create mode 100644 lib/MooseX/Net/API/Role/Serialize.pm (limited to 'lib/MooseX/Net/API') diff --git a/lib/MooseX/Net/API/Role/Deserialize.pm b/lib/MooseX/Net/API/Role/Deserialize.pm new file mode 100644 index 0000000..105fb6b --- /dev/null +++ b/lib/MooseX/Net/API/Role/Deserialize.pm @@ -0,0 +1,21 @@ +package MooseX::Net::API::Roles::Deserialize; + +use Moose::Role; +use JSON::XS; +use YAML::Syck; +use XML::Simple; + +sub _from_json { + return decode_json( $_[1] ); +} + +sub _from_yaml { + return Dump $_[1]; +} + +sub _from_xml { + my $xml = XML::Simple->new( ForceArray => 0 ); + $xml->XMLout( { data => $_[0] } ); +} + +1; diff --git a/lib/MooseX/Net/API/Role/Serialize.pm b/lib/MooseX/Net/API/Role/Serialize.pm new file mode 100644 index 0000000..20e2b97 --- /dev/null +++ b/lib/MooseX/Net/API/Role/Serialize.pm @@ -0,0 +1,21 @@ +package MooseX::Net::API::Roles::Serialize; + +use Moose::Role; +use JSON::XS; +use YAML::Syck; +use XML::Simple; + +sub _to_json { + return encode_json( $_[1] ); +} + +sub _to_yaml { + return Load $_[1]; +} + +sub _to_xml { + my $xml = XML::Simple->new( ForceArray => 0 ); + $xml->XMLin("$_[0]"); +} + +1; -- cgit 1.4.1