Change all classes to Moose
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Serialize / YAML.pm
CommitLineData
256c894f 1package Catalyst::Action::Serialize::YAML;
2
930013e6 3use Moose;
4use namespace::autoclean;
256c894f 5
930013e6 6extends 'Catalyst::Action';
256c894f 7use YAML::Syck;
8
9sub execute {
10 my $self = shift;
e601adda 11 my ( $controller, $c ) = @_;
256c894f 12
faf5c20b 13 my $stash_key = (
07682cbc 14 $controller->{'serialize'} ?
15 $controller->{'serialize'}->{'stash_key'} :
16 $controller->{'stash_key'}
faf5c20b 17 ) || 'rest';
e601adda 18 my $output;
19 eval {
485b5160 20 $output = $self->serialize($c->stash->{$stash_key});
e601adda 21 };
22 if ($@) {
23 return $@;
24 }
25 $c->response->output( $output );
256c894f 26 return 1;
eccb2137 27}
256c894f 28
485b5160 29sub serialize {
30 my $self = shift;
31 my $data = shift;
32 Dump($data);
33}
34
256c894f 351;