X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FAction%2FDeserialize%2FYAML.pm;h=439c6e6766f4836def7ea011565cae81cc177ea1;hb=96a61a601b093754a99bb61b57e41dbfc3228ad7;hp=aa6c4117c461f11815c9c5d48a00eb076378ccf2;hpb=7ad87df957f65463dba321ebe616e2581b7ff58f;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Deserialize/YAML.pm b/lib/Catalyst/Action/Deserialize/YAML.pm index aa6c411..439c6e6 100644 --- a/lib/Catalyst/Action/Deserialize/YAML.pm +++ b/lib/Catalyst/Action/Deserialize/YAML.pm @@ -1,29 +1,35 @@ -# -# Catlyst::Action::Deserialize::YAML.pm -# Created by: Adam Jacob, Marchex, -# Created on: 10/12/2006 03:00:32 PM PDT -# -# $Id$ - package Catalyst::Action::Deserialize::YAML; -use strict; -use warnings; +use Moose; +use namespace::autoclean; -use base 'Catalyst::Action'; +extends 'Catalyst::Action'; use YAML::Syck; +our $VERSION = '0.84'; +$VERSION = eval $VERSION; + sub execute { my $self = shift; my ( $controller, $c, $test ) = @_; - + my $body = $c->request->body; if ($body) { - my $rdata = LoadFile($c->request->body); + my $rdata; + eval { + my $body = $c->request->body; + $rdata = LoadFile( "$body" ); + }; + if ($@) { + return $@; + } $c->request->data($rdata); } else { - $c->log->debug('I would have deserialized, but there was nothing in the body!'); + $c->log->debug( + 'I would have deserialized, but there was nothing in the body!') + if $c->debug; } -}; + return 1; +} 1;