perltidy all classes
[catagits/Catalyst-Controller-DBIC-API.git] / lib / Catalyst / Controller / DBIC / API / RPC.pm
CommitLineData
d2739840 1package Catalyst::Controller::DBIC::API::RPC;
8ea592cb 2
d2739840 3#ABSTRACT: Provides an RPC interface to DBIx::Class
4
5use Moose;
6BEGIN { extends 'Catalyst::Controller::DBIC::API'; }
7
8__PACKAGE__->config(
406086f3 9 'action' => { object_with_id => { PathPart => 'id' } },
d2739840 10 'default' => 'application/json',
11 'stash_key' => 'response',
12 'map' => {
13 'application/x-www-form-urlencoded' => 'JSON',
14 'application/json' => 'JSON',
15 },
16);
17
18=head1 DESCRIPTION
19
406086f3 20Provides an RPC API interface to the functionality described in L<Catalyst::Controller::DBIC::API>.
d2739840 21
22By default provides the following endpoints:
23
24 $base/create
25 $base/list
609916e5 26 $base/id/[identifier]
d2739840 27 $base/id/[identifier]/delete
28 $base/id/[identifier]/update
29
30Where $base is the URI described by L</setup>, the chain root of the controller.
31
32=method_protected setup
33
34Chained: override
35PathPart: override
36CaptureArgs: 0
37
38As described in L<Catalyst::Controller::DBIC::API/setup>, this action is the chain root of the controller but has no pathpart or chain parent defined by default, so these must be defined in order for the controller to function. The neatest way is normally to define these using the controller's config.
39
40 __PACKAGE__->config
406086f3 41 ( action => { setup => { PathPart => 'track', Chained => '/api/rpc/rpc_base' } },
d2739840 42 ...
43 );
44
d2739840 45=cut
46
d2739840 47=method_protected create
48
533075c7 49Chained: L</objects_no_id>
d2739840 50PathPart: create
51CaptureArgs: 0
52
53Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
54
55=cut
56
8ea592cb 57sub create : Chained('objects_no_id') : PathPart('create') : Args(0) {
58 my ( $self, $c ) = @_;
3d85db11 59 $self->update_or_create($c);
d2739840 60}
61
62=method_protected list
63
609916e5 64Chained: L</deserialize>
d2739840 65PathPart: list
66CaptureArgs: 0
67
68Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/list>.
69
70=cut
71
8ea592cb 72sub list : Chained('deserialize') : PathPart('list') : Args(0) {
73 my ( $self, $c ) = @_;
533075c7 74 $self->next::method($c);
d2739840 75}
76
609916e5 77=method_protected item
78
79Chained: L</object_with_id>
80PathPart: ''
81Args: 0
82
83Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/item>.
84
85=cut
86
8ea592cb 87sub item : Chained('object_with_id') : PathPart('') : Args(0) {
88 my ( $self, $c ) = @_;
533075c7 89 $self->next::method($c);
609916e5 90}
91
d2739840 92=method_protected update
93
609916e5 94Chained: L</object_with_id>
d2739840 95PathPart: update
609916e5 96Args: 0
d2739840 97
98Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create>.
99
100=cut
101
8ea592cb 102sub update : Chained('object_with_id') : PathPart('update') : Args(0) {
103 my ( $self, $c ) = @_;
3d85db11 104 $self->update_or_create($c);
d2739840 105}
106
107=method_protected delete
108
609916e5 109Chained: L</object_with_id>
d2739840 110PathPart: delete
609916e5 111Args: 0
d2739840 112
113Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete>.
114
115=cut
116
8ea592cb 117sub delete : Chained('object_with_id') : PathPart('delete') : Args(0) {
118 my ( $self, $c ) = @_;
609916e5 119 $self->next::method($c);
120}
d2739840 121
609916e5 122=method_protected update_bulk
123
533075c7 124Chained: L</objects_no_id>
609916e5 125PathPart: update
126Args: 0
127
128Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/update_or_create> for multiple objects.
129
130=cut
131
8ea592cb 132sub update_bulk : Chained('objects_no_id') : PathPart('update') : Args(0) {
133 my ( $self, $c ) = @_;
3d85db11 134 $self->update_or_create($c);
609916e5 135}
136
137=method_protected delete_bulk
138
533075c7 139Chained: L</objects_no_id>
609916e5 140PathPart: delete
141Args: 0
142
143Provides an endpoint to the functionality described in L<Catalyst::Controller::DBIC::API/delete> for multiple objects.
144
145=cut
146
8ea592cb 147sub delete_bulk : Chained('objects_no_id') : PathPart('delete') : Args(0) {
148 my ( $self, $c ) = @_;
a1f71064 149 $self->delete($c);
d2739840 150}
151
1521;