remove hardcoded version strings
[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
cc188065 8# VERSION
f465980c 9
e601adda 10sub execute {
11 my $self = shift;
12 my ( $controller, $c ) = @_;
13
14 eval {
15 require XML::Simple
16 };
17 if ($@) {
d4611771 18 $c->log->debug("Could not load XML::Serializer, refusing to serialize: $@")
19 if $c->debug;
7f36b63e 20 return;
e601adda 21 }
22 my $xs = XML::Simple->new(ForceArray => 0,);
23
faf5c20b 24 my $stash_key = (
07682cbc 25 $controller->{'serialize'} ?
26 $controller->{'serialize'}->{'stash_key'} :
27 $controller->{'stash_key'}
faf5c20b 28 ) || 'rest';
7f36b63e 29 my $output = $xs->XMLout({ data => $c->stash->{$stash_key} });
e601adda 30 $c->response->output( $output );
31 return 1;
32}
33
24748286 34__PACKAGE__->meta->make_immutable;
35
e601adda 361;