End point clean up and alter forwards to method calls in end points
nperez [Mon, 1 Mar 2010 17:42:22 +0000 (11:42 -0600)]
lib/Catalyst/Controller/DBIC/API.pm
lib/Catalyst/Controller/DBIC/API/REST.pm
lib/Catalyst/Controller/DBIC/API/RPC.pm

index 422dc54..fbf3329 100644 (file)
@@ -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</setup>. List's steps are broken up into three distinct methods: L</list_munge_parameters>, L</list_perform_search>, and L</list_format_output>.
+list's steps are broken up into three distinct methods: L</list_munge_parameters>, L</list_perform_search>, and L</list_format_output>.
 
 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</create_requires> and L</create_allows> (or L</update_allows>) parameters of the controller config. The objects are then committed within a transaction via L</transact_objects> using a closure around L</save_objects>.
 
 =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</transact_objects> and a closure around L</delete_objects>, 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;
index 23655e2..a66cb8d 100644 (file)
@@ -42,7 +42,7 @@ Chained: L</objects_no_id>
 PathPart: none
 CaptureArgs: 0
 
-Forwards to list level methods described in L<Catalyst::Controller::DBIC::API> as follows:
+Calls list level methods described in L<Catalyst::Controller::DBIC::API> as follows:
 
 DELETE: L<Catalyst::Controller::DBIC::API/delete>
 POST/PUT: L<Catalyst::Controller::DBIC::API/update_or_create>
@@ -50,30 +50,30 @@ GET: forwards to L<Catalyst::Controller::DBIC::API/list>
 
 =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<Catalyst::Controller::DBIC::API/item>
 
 =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;
index abcf404..e9ff286 100644 (file)
@@ -60,10 +60,10 @@ Provides an endpoint to the functionality described in L<Catalyst::Controller::D
 
 =cut
 
-sub create :Chained('objects_no_id') :PathPart('create')
+sub create :Chained('objects_no_id') :PathPart('create') :Args(0) 
 {
        my ($self, $c) = @_;
-    $c->forward('update_or_create');
+    $self->update_or_create($c);
 }
 
 =method_protected list
@@ -76,7 +76,7 @@ Provides an endpoint to the functionality described in L<Catalyst::Controller::D
 
 =cut
 
-sub list :Chained('deserialize') :PathPart('list')
+sub list :Chained('deserialize') :PathPart('list') :Args(0) 
 {
        my ($self, $c) = @_;
     $self->next::method($c);
@@ -92,7 +92,7 @@ Provides an endpoint to the functionality described in L<Catalyst::Controller::D
 
 =cut
 
-sub item :Chained('object_with_id') :PathPart('')
+sub item :Chained('object_with_id') :PathPart('') :Args(0) 
 {
     my ($self, $c) = @_;
     $self->next::method($c);
@@ -108,10 +108,10 @@ Provides an endpoint to the functionality described in L<Catalyst::Controller::D
 
 =cut
 
-sub update :Chained('object_with_id') :PathPart('update')
+sub update :Chained('object_with_id') :PathPart('update') :Args(0) 
 {
     my ($self, $c) = @_;
-    $c->forward('update_or_create');
+    $self->update_or_create($c);
 }
 
 =method_protected delete
@@ -124,7 +124,7 @@ Provides an endpoint to the functionality described in L<Catalyst::Controller::D
 
 =cut
 
-sub delete :Chained('object_with_id') :PathPart('delete')
+sub delete :Chained('object_with_id') :PathPart('delete') :Args(0) 
 {
     my ($self, $c) = @_;
     $self->next::method($c);
@@ -140,10 +140,10 @@ Provides an endpoint to the functionality described in L<Catalyst::Controller::D
 
 =cut
 
-sub update_bulk :Chained('objects_no_id') :PathPart('update')
+sub update_bulk :Chained('objects_no_id') :PathPart('update') :Args(0) 
 {
     my ($self, $c) = @_;
-    $c->forward('update_or_create');
+    $self->update_or_create($c);
 }
 
 =method_protected delete_bulk
@@ -156,7 +156,7 @@ Provides an endpoint to the functionality described in L<Catalyst::Controller::D
 
 =cut
 
-sub delete_bulk :Chained('objects_no_id') :PathPart('delete')
+sub delete_bulk :Chained('objects_no_id') :PathPart('delete') :Args(0) 
 {
     my ($self, $c) = @_;
     $self->next::method($c);