r49@latte: adam | 2006-12-03 12:30:40 -0800
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Deserialize / YAML.pm
CommitLineData
256c894f 1#
2# Catlyst::Action::Deserialize::YAML.pm
3# Created by: Adam Jacob, Marchex, <adam@marchex.com>
4# Created on: 10/12/2006 03:00:32 PM PDT
5#
6# $Id$
7
8package Catalyst::Action::Deserialize::YAML;
9
10use strict;
11use warnings;
12
13use base 'Catalyst::Action';
14use YAML::Syck;
256c894f 15
16sub execute {
17 my $self = shift;
18 my ( $controller, $c, $test ) = @_;
eccb2137 19
7ad87df9 20 my $body = $c->request->body;
21 if ($body) {
e601adda 22 my $rdata;
23 eval {
24 $rdata = LoadFile( $c->request->body );
25 };
26 if ($@) {
27 return $@;
28 }
256c894f 29 $c->request->data($rdata);
256c894f 30 } else {
eccb2137 31 $c->log->debug(
32 'I would have deserialized, but there was nothing in the body!');
256c894f 33 }
e601adda 34 return 1;
eccb2137 35}
256c894f 36
371;