From: nperez Date: Mon, 1 Mar 2010 17:42:22 +0000 (-0600) Subject: End point clean up and alter forwards to method calls in end points X-Git-Tag: 2.002001~18 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Controller-DBIC-API.git;a=commitdiff_plain;h=3d85db11441182964cf35818ed25265eec1b74e2;hp=9a29ee35ad6dba84d7741dc1e115fe90583a5d88 End point clean up and alter forwards to method calls in end points --- diff --git a/lib/Catalyst/Controller/DBIC/API.pm b/lib/Catalyst/Controller/DBIC/API.pm index 422dc54..fbf3329 100644 --- a/lib/Catalyst/Controller/DBIC/API.pm +++ b/lib/Catalyst/Controller/DBIC/API.pm @@ -72,7 +72,6 @@ sub begin :Private unless Moose::Util::does_role($c->req, 'Catalyst::Controller::DBIC::API::Request'); } - =method_protected setup :Chained('specify.in.subclass.config') :CaptureArgs(0) :PathPart('specify.in.subclass.config') @@ -185,7 +184,6 @@ sub generate_rs return $self->stored_result_source->resultset; } - =method_protected inflate_request inflate_request is called at the end of deserialize to populate key portions of the request with the useful bits @@ -329,9 +327,7 @@ sub object_lookup =method_protected list - :Private - -List level action chained from L. List's steps are broken up into three distinct methods: L, L, and L. +list's steps are broken up into three distinct methods: L, L, and L. The goal of this method is to call ->search() on the current_result_set, HashRefInflator the result, and return it in $c->stash->{response}->{$self->data_root}. Please see the individual methods for more details on what actual processing takes place. @@ -363,7 +359,7 @@ Would result in this search: =cut -sub list :Private +sub list { my ($self, $c) = @_; @@ -469,14 +465,12 @@ sub row_format_output } =method_protected item - - :Private item will return a single object called by identifier in the uri. It will be inflated via each_object_inflate. =cut -sub item :Private +sub item { my ($self, $c) = @_; @@ -492,16 +486,13 @@ sub item :Private } } - =method_protected update_or_create - :Private - update_or_create is responsible for iterating any stored objects and performing updates or creates. Each object is first validated to ensure it meets the criteria specified in the L and L (or L) parameters of the controller config. The objects are then committed within a transaction via L using a closure around L. =cut -sub update_or_create :Private +sub update_or_create { my ($self, $c) = @_; @@ -665,13 +656,11 @@ sub validate_object =method_protected delete - :Private - delete operates on the stored objects in the request. It first transacts the objects, deleting them in the database using L and a closure around L, and then clears the request store of objects. =cut -sub delete :Private +sub delete { my ($self, $c) = @_; @@ -803,13 +792,11 @@ sub delete_object =method_protected end - :Private - end performs the final manipulation of the response before it is serialized. This includes setting the success of the request both at the HTTP layer and JSON layer. If configured with return_object true, and there are stored objects as the result of create or update, those will be inflated according to the schema and get_inflated_columns =cut -sub end :Private +sub end :Private { my ($self, $c) = @_; @@ -1049,7 +1036,6 @@ For example if you wanted create to return the JSON for the newly created object } } - package MyApp::Controller::API::RPC::Track; ... use Moose; diff --git a/lib/Catalyst/Controller/DBIC/API/REST.pm b/lib/Catalyst/Controller/DBIC/API/REST.pm index 23655e2..a66cb8d 100644 --- a/lib/Catalyst/Controller/DBIC/API/REST.pm +++ b/lib/Catalyst/Controller/DBIC/API/REST.pm @@ -42,7 +42,7 @@ Chained: L PathPart: none CaptureArgs: 0 -Forwards to list level methods described in L as follows: +Calls list level methods described in L as follows: DELETE: L POST/PUT: L @@ -50,30 +50,30 @@ GET: forwards to L =cut -sub no_id : Chained('objects_no_id') PathPart('') ActionClass('REST') {} +sub no_id : Chained('objects_no_id') PathPart('') ActionClass('REST') :Args(0) {} sub no_id_PUT { my ( $self, $c ) = @_; - $c->forward('update_or_create'); + $self->update_or_create($c); } sub no_id_POST { my ( $self, $c ) = @_; - $c->forward('update_or_create'); + $self->update_or_create($c); } sub no_id_DELETE { my ( $self, $c ) = @_; - $c->forward('delete'); + $self->delete($c); } sub no_id_GET { my ( $self, $c ) = @_; - $c->forward('list'); + $self->list($c); } =method_protected with_id @@ -90,30 +90,30 @@ GET: forwards to L =cut -sub with_id :Chained('object_with_id') :PathPart('') :ActionClass('REST') {} +sub with_id :Chained('object_with_id') :PathPart('') :ActionClass('REST') :Args(0) {} sub with_id_PUT { my ( $self, $c ) = @_; - $c->forward('update_or_create'); + $self->update_or_create($c); } sub with_id_POST { my ( $self, $c ) = @_; - $c->forward('update_or_create'); + $self->update_or_create($c); } sub with_id_DELETE { my ( $self, $c ) = @_; - $c->forward('delete'); + $self->delete($c); } sub with_id_GET { my ( $self, $c ) = @_; - $c->forward('item'); + $self->item($c); } 1; diff --git a/lib/Catalyst/Controller/DBIC/API/RPC.pm b/lib/Catalyst/Controller/DBIC/API/RPC.pm index abcf404..e9ff286 100644 --- a/lib/Catalyst/Controller/DBIC/API/RPC.pm +++ b/lib/Catalyst/Controller/DBIC/API/RPC.pm @@ -60,10 +60,10 @@ Provides an endpoint to the functionality described in Lforward('update_or_create'); + $self->update_or_create($c); } =method_protected list @@ -76,7 +76,7 @@ Provides an endpoint to the functionality described in Lnext::method($c); @@ -92,7 +92,7 @@ Provides an endpoint to the functionality described in Lnext::method($c); @@ -108,10 +108,10 @@ Provides an endpoint to the functionality described in Lforward('update_or_create'); + $self->update_or_create($c); } =method_protected delete @@ -124,7 +124,7 @@ Provides an endpoint to the functionality described in Lnext::method($c); @@ -140,10 +140,10 @@ Provides an endpoint to the functionality described in Lforward('update_or_create'); + $self->update_or_create($c); } =method_protected delete_bulk @@ -156,7 +156,7 @@ Provides an endpoint to the functionality described in Lnext::method($c);