Configuration patches to handle component based configuration in a sane way, as well...
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Action / Deserialize / YAML.pm
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
8 package Catalyst::Action::Deserialize::YAML;
9
10 use strict;
11 use warnings;
12
13 use base 'Catalyst::Action';
14 use YAML::Syck;
15
16 sub execute {
17     my $self = shift;
18     my ( $controller, $c, $test ) = @_;
19
20     my $body = $c->request->body;
21     if ($body) {
22         my $rdata;
23         eval {
24             $rdata = LoadFile( $c->request->body );
25         };
26         if ($@) {
27             return $@;
28         }
29         $c->request->data($rdata);
30     } else {
31         $c->log->debug(
32             'I would have deserialized, but there was nothing in the body!')
33             if $c->debug;
34     }
35     return 1;
36 }
37
38 1;