X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FSerialize%2FXML%2FSimple.pm;h=82377e626898798bbc24981c7ca501a907b893e2;hb=fc97153d494ce8d5dbdaffd2c91925bc3b4de04c;hp=fe0b5c125068070674348b87df323775cda4110f;hpb=c9cf872989c719198a088b65c9b6db1a94364c96;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Serialize/XML/Simple.pm b/lib/Catalyst/Action/Serialize/XML/Simple.pm index fe0b5c1..82377e6 100644 --- a/lib/Catalyst/Action/Serialize/XML/Simple.pm +++ b/lib/Catalyst/Action/Serialize/XML/Simple.pm @@ -1,45 +1,14 @@ -# -# Catlyst::Action::Serialize::XML::Simple.pm -# Created by: Adam Jacob, Marchex, -# Created on: 10/12/2006 03:00:32 PM PDT -# -# $Id$ - package Catalyst::Action::Serialize::XML::Simple; - -use strict; -use warnings; - -use base 'Catalyst::Action'; - -sub execute { - my $self = shift; - my ( $controller, $c ) = @_; - - eval { - require XML::Simple - }; - if ($@) { - $c->log->debug("Could not load XML::Serializer, refusing to serialize: $@") - if $c->debug; - return 0; - } - my $xs = XML::Simple->new(ForceArray => 0,); - - my $stash_key = ( - $controller->{'serialize'} ? - $controller->{'serialize'}->{'stash_key'} : - $controller->{'stash_key'} - ) || 'rest'; - my $output; - eval { - $output = $xs->XMLout({ data => $c->stash->{$stash_key} }); - }; - if ($@) { - return $@; - } - $c->response->output( $output ); - return 1; +use Moose; +extends 'Catalyst::Action'; +with 'Catalyst::ActionRole::Serialize'; +use XML::Simple; +use namespace::clean -except => 'meta'; + +sub serialize { + my ($self, $data, $c) = @_; + my $x = XML::Simple->new(ForceArray => 0); + return $x->XMLout({ data => $data }); } 1;