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