Bump versions for release
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / XML / Simple.pm
CommitLineData
e601adda 1package Catalyst::Action::Serialize::XML::Simple;
2
930013e6 3use Moose;
4use namespace::autoclean;
e601adda 5
930013e6 6extends 'Catalyst::Action';
e601adda 7
3bb36dca 8our $VERSION = '0.82';
f465980c 9$VERSION = eval $VERSION;
10
e601adda 11sub execute {
12 my $self = shift;
13 my ( $controller, $c ) = @_;
14
15 eval {
16 require XML::Simple
17 };
18 if ($@) {
d4611771 19 $c->log->debug("Could not load XML::Serializer, refusing to serialize: $@")
20 if $c->debug;
7f36b63e 21 return;
e601adda 22 }
23 my $xs = XML::Simple->new(ForceArray => 0,);
24
faf5c20b 25 my $stash_key = (
07682cbc 26 $controller->{'serialize'} ?
27 $controller->{'serialize'}->{'stash_key'} :
28 $controller->{'stash_key'}
faf5c20b 29 ) || 'rest';
7f36b63e 30 my $output = $xs->XMLout({ data => $c->stash->{$stash_key} });
e601adda 31 $c->response->output( $output );
32 return 1;
33}
34
351;