From 1551d1e17735060fcb76ebb71bb26a964518b9b1 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Tue, 8 Dec 2009 16:11:58 +0100 Subject: move serialize into a role --- lib/MooseX/Net/API/Role/Serialize.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/MooseX/Net/API/Role/Serialize.pm b/lib/MooseX/Net/API/Role/Serialize.pm index 1218af3..016a290 100644 --- a/lib/MooseX/Net/API/Role/Serialize.pm +++ b/lib/MooseX/Net/API/Role/Serialize.pm @@ -10,7 +10,7 @@ sub _to_json { } sub _to_yaml { - return Load $_[1]; + return Dump $_[1]; } sub _to_xml { @@ -18,4 +18,16 @@ sub _to_xml { $xml->XMLin("$_[0]"); } +sub _do_serialization { + my ( $caller, $content, $format ) = @_; + + my $format_content; + my $method = '_to_' . $format; + return if ( !$caller->meta->find_method_by_name($method) ); + try { + $format_content = $caller->$method($content); + }; + return $format_content if $format_content; +} + 1; -- cgit 1.4.1