diff options
author | franck cuny <franck@lumberjaph.net> | 2010-06-03 10:01:01 +0200 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-06-03 10:01:01 +0200 |
commit | 3da11a8153d3b42af2f2a250008be6cc52e57b09 (patch) | |
tree | 4da02b541e9f8d35e5f20d63908cd33fe64dc7f8 /lib/MooseX/Net/API/Role/Deserialize.pm | |
parent | replace remainging with nothing (diff) | |
parent | fix attribute declaration (diff) | |
download | moosex-net-api-3da11a8153d3b42af2f2a250008be6cc52e57b09.tar.gz |
merge
Diffstat (limited to '')
-rw-r--r-- | lib/MooseX/Net/API/Role/Deserialize.pm | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/lib/MooseX/Net/API/Role/Deserialize.pm b/lib/MooseX/Net/API/Role/Deserialize.pm deleted file mode 100644 index cf69087..0000000 --- a/lib/MooseX/Net/API/Role/Deserialize.pm +++ /dev/null @@ -1,49 +0,0 @@ -package MooseX::Net::API::Role::Deserialize; - -use Moose::Role; -use JSON::XS; -use YAML::Syck; -use XML::Simple; -use Try::Tiny; - -my $reverse_content_type = { - 'application/json' => 'json', - 'application/x-yaml' => 'yaml', - 'text/xml' => 'xml', - 'application/xml' => 'xml', -}; - -sub _from_json { - return decode_json( $_[1] ); -} - -sub _from_yaml { - return Load $_[1]; -} - -sub _from_xml { - my $xml = XML::Simple->new( ForceArray => 0 ); - $xml->XMLin( $_[1] ); -} - -sub _do_deserialization { - my ( $caller, $raw_content, @content_types ) = @_; - - my $content; - foreach my $deserializer (@content_types) { - my $method; - if ( $reverse_content_type->{$deserializer} ) { - $method = '_from_' . $reverse_content_type->{$deserializer}; - } - else { - $method = '_from_' . $deserializer; - } - next if ( !$caller->meta->find_method_by_name($method) ); - try { - $content = $caller->$method($raw_content); - }; - return $content if $content; - } -} - -1; |