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=56ecb52740e17c1512a3a4896c3a74b321ea0bfd;hpb=256c894fcf95e1a0716676afb8f5732854734672;p=catagits%2FCatalyst-Action-REST.git diff --git a/lib/Catalyst/Action/Deserialize/YAML.pm b/lib/Catalyst/Action/Deserialize/YAML.pm index 56ecb52..439c6e6 100644 --- a/lib/Catalyst/Action/Deserialize/YAML.pm +++ b/lib/Catalyst/Action/Deserialize/YAML.pm @@ -1,32 +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; -use Catalyst::Request::REST; + +our $VERSION = '0.84'; +$VERSION = eval $VERSION; sub execute { my $self = shift; my ( $controller, $c, $test ) = @_; - - my $nreq = bless($c->request, 'Catalyst::Request::REST'); - $c->request($nreq); - if ($c->request->method eq "POST" || $c->request->method eq "PUT") { - my $rdata = LoadFile($c->request->body); + + my $body = $c->request->body; + if ($body) { + my $rdata; + eval { + my $body = $c->request->body; + $rdata = LoadFile( "$body" ); + }; + if ($@) { + return $@; + } $c->request->data($rdata); - $self->NEXT::execute( @_, ); } else { - $self->NEXT::execute( @_ ); + $c->log->debug( + 'I would have deserialized, but there was nothing in the body!') + if $c->debug; } -}; + return 1; +} 1;