Change all classes to Moose
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Deserialize / YAML.pm
CommitLineData
256c894f 1package Catalyst::Action::Deserialize::YAML;
2
930013e6 3use Moose;
4use namespace::autoclean;
256c894f 5
930013e6 6extends 'Catalyst::Action';
256c894f 7use YAML::Syck;
256c894f 8
9sub execute {
10 my $self = shift;
11 my ( $controller, $c, $test ) = @_;
eccb2137 12
7ad87df9 13 my $body = $c->request->body;
14 if ($body) {
e601adda 15 my $rdata;
16 eval {
c28a55ff 17 my $body = $c->request->body;
18 $rdata = LoadFile( "$body" );
e601adda 19 };
20 if ($@) {
21 return $@;
22 }
256c894f 23 $c->request->data($rdata);
256c894f 24 } else {
eccb2137 25 $c->log->debug(
faf5c20b 26 'I would have deserialized, but there was nothing in the body!')
27 if $c->debug;
256c894f 28 }
e601adda 29 return 1;
eccb2137 30}
256c894f 31
321;