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