[Catalyst-commits] r9091 - in trunk/Catalyst-Model-DBIC-Schema: . lib/Catalyst/Model/DBIC

jgottshall at dev.catalyst.perl.org jgottshall at dev.catalyst.perl.org
Thu Jan 15 18:55:00 GMT 2009


Author: jgottshall
Date: 2009-01-15 18:54:59 +0000 (Thu, 15 Jan 2009)
New Revision: 9091

Modified:
   trunk/Catalyst-Model-DBIC-Schema/Changes
   trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
Log:
Doc patch to clarify generated classes


Modified: trunk/Catalyst-Model-DBIC-Schema/Changes
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/Changes	2009-01-14 19:06:30 UTC (rev 9090)
+++ trunk/Catalyst-Model-DBIC-Schema/Changes	2009-01-15 18:54:59 UTC (rev 9091)
@@ -2,6 +2,7 @@
 
 0.22  Pending
 		- Fix oddly formatted error message.
+        - Doc patch to clarify generated classes
 
 0.21  Fri Aug 22 00:26:05 UTC 2008
         - doc fix (RT #31848)

Modified: trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm
===================================================================
--- trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm	2009-01-14 19:06:30 UTC (rev 9090)
+++ trunk/Catalyst-Model-DBIC-Schema/lib/Catalyst/Model/DBIC/Schema.pm	2009-01-15 18:54:59 UTC (rev 9091)
@@ -102,10 +102,10 @@
       password_field  => 'password'
   }
 
-C<< $c->model() >> returns a L<DBIx::Class::ResultSet> for the source name
-parameter passed. To find out more about which methods can be called on a
-ResultSet, or how to add your own methods to it, please see the ResultSet
-documentation in the L<DBIx::Class> distribution.
+C<< $c->model('Schema::Source') >> returns a L<DBIx::Class::ResultSet> for 
+the source name parameter passed. To find out more about which methods can 
+be called on a ResultSet, or how to add your own methods to it, please see 
+the ResultSet documentation in the L<DBIx::Class> distribution.
 
 Some examples are given below:
 
@@ -143,6 +143,38 @@
 the documentation for L<Catalyst::Helper::Model::DBIC::Schema> for
 information on generating these Models via Helper scripts.
 
+When your Catalyst app starts up, a thin Model layer is created as an 
+interface to your DBIC Schema. It should be clearly noted that the model 
+object returned by C<< $c->model('FilmDB') >> is NOT itself a DBIC schema or 
+resultset object, but merely a wrapper proving L<methods|/METHODS> to access 
+the underlying schema. 
+
+In addition to this model class, a shortcut class is generated for each 
+source in the schema, allowing easy and direct access to a resultset of the 
+corresponding type. These generated classes are even thinner than the model 
+class, providing no public methods but simply hooking into Catalyst's 
+model() accessor via the 
+L<ACCEPT_CONTEXT|Catalyst::Component/ACCEPT_CONTEXT> mechanism. The complete 
+contents of each generated class is roughly equivalent to the following:
+
+  package MyApp::Model::FilmDB::Actor
+  sub ACCEPT_CONTEXT {
+      my ($self, $c) = @_;
+      $c->model('FilmDB')->resultset('Actor');
+  }
+
+In short, there are three techniques available for obtaining a DBIC 
+resultset object: 
+
+  # the long way
+  my $rs = $c->model('FilmDB')->schema->resultset('Actor');
+
+  # using the shortcut method on the model object
+  my $rs = $c->model('FilmDB')->resultset('Actor');
+
+  # using the generated class directly
+  my $rs = $c->model('FilmDB::Actor');
+
 =head1 CONFIG PARAMETERS
 
 =over 4




More information about the Catalyst-commits mailing list