Bump versions for release
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Deserialize / YAML.pm
1 package Catalyst::Action::Deserialize::YAML;
2
3 use Moose;
4 use namespace::autoclean;
5
6 extends 'Catalyst::Action';
7 use YAML::Syck;
8
9 our $VERSION = '0.82';
10 $VERSION = eval $VERSION;
11
12 sub execute {
13     my $self = shift;
14     my ( $controller, $c, $test ) = @_;
15
16     my $body = $c->request->body;
17     if ($body) {
18         my $rdata;
19         eval {
20             my $body = $c->request->body;
21             $rdata = LoadFile( "$body" );
22         };
23         if ($@) {
24             return $@;
25         }
26         $c->request->data($rdata);
27     } else {
28         $c->log->debug(
29             'I would have deserialized, but there was nothing in the body!')
30             if $c->debug;
31     }
32     return 1;
33 }
34
35 1;