Implement generate_rs to provide a default implementation for getting the resultset...
nperez [Mon, 1 Mar 2010 17:03:38 +0000 (11:03 -0600)]
Changes
lib/Catalyst/Controller/DBIC/API.pm

diff --git a/Changes b/Changes
index 4593d83..8ce3904 100644 (file)
--- a/Changes
+++ b/Changes
@@ -11,6 +11,7 @@ Revision history for Catalyst-Controller-DBIC-API: {{ $dist->version }}
 - Chain dispatching has now been fixed to not be as hackish as before
 - Shift around where the current result set is set. setup() now does /nothing/ by default other than be a chain anchor
 - Tests added for updating related keys via REST
+- generate_rs is now used to get the default resultset inside inflate_request
 - PLEASE THOROUGHLY TEST AS SOME BEHAVIOR MAY HAVE BEEN ALTERED SUBTLY WHEN DEALING WITH BULK vs SINGLE ACTIONS
 
 2.001003  2010-02-12 19:01:56 America/Chicago
index e257ed1..422dc54 100644 (file)
@@ -173,6 +173,19 @@ sub deserialize :Chained('setup') :CaptureArgs(0) :PathPart('') :ActionClass('De
     $self->inflate_request($c, $req_params);
 }
 
+=method_protected generate_rs
+
+generate_rs is used by inflate_request to generate the resultset stored in the current request. It receives $c as its only argument. And by default it merely returns the resultset from the stored_result_source on the controller. Override this method if you need to manipulate the default implementation of getting the resultset from the controller.
+
+=cut
+
+sub generate_rs
+{
+    my ($self, $c) = @_;
+    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
@@ -192,7 +205,7 @@ sub inflate_request
         $c->req->_set_request_data($params);
 
         # set the current resultset
-        $c->req->_set_current_result_set($self->stored_result_source->resultset);
+        $c->req->_set_current_result_set($self->generate_rs($c));
         
     }
     catch