refactor serialize actions
[catagits/Catalyst-Action-REST.git] / lib / Catalyst / Request / REST.pm
1 #
2 # REST.pm
3 # Created by: Adam Jacob, Marchex, <adam@hjksolutions.com>
4 # Created on: 10/13/2006 03:54:33 PM PDT
5 #
6 # $Id: $
7
8 package Catalyst::Request::REST;
9
10 use strict;
11 use warnings;
12
13 use Moose;
14 extends qw/Catalyst::Request Class::Accessor::Fast/;
15 with 'Catalyst::RequestRole::REST';
16
17 use Catalyst::Utils;
18
19 sub _insert_self_into {
20   my ($class, $app_class ) = @_;
21   # the fallback to $app_class is for the (rare and deprecated) case when
22   # people are defining actions in MyApp.pm instead of in a controller.
23   my $app = Catalyst::Utils::class2appclass( $app_class ) || $app_class;
24
25   my $req_class = $app->request_class;
26   return if $req_class->isa($class);
27   if ($req_class eq 'Catalyst::Request') {
28     $app->request_class($class);
29   } else {
30     die "$app has a custom request class $req_class, "
31       . "which is not a $class; see Catalyst::Request::REST";
32   }
33 }
34
35 =head1 NAME
36
37 Catalyst::Request::REST - A REST-y subclass of Catalyst::Request
38
39 =head1 METHODS
40
41 If the request went through the Deserializer action, this method will
42 returned the deserialized data structure.
43
44 =cut
45
46 __PACKAGE__->mk_accessors(qw(data));
47
48 =head1 AUTHOR
49
50 Adam Jacob <adam@stalecoffee.org>, with lots of help from mst and jrockway
51
52 =head1 MAINTAINER
53
54 J. Shirley <jshirley@cpan.org>
55
56 =head1 LICENSE
57
58 You may distribute this code under the same terms as Perl itself.
59
60 =cut
61
62 1;