[Catalyst] Reference to the connected Model::DBIC schema for testing?

Matt S Trout dbix-class at trout.me.uk
Thu Oct 12 19:53:12 CEST 2006


Jesper Krogh wrote:
> Matt S Trout wrote:
>> Drew Taylor wrote:
>>> On 10/10/06, Matt S Trout <dbix-class at trout.me.uk> wrote:
>>>> my $model_dbic_schema_object = MyApp->model('Foo');
>>> Shouldn't the name actually be "$model_dbic_resultset_object"? I'm
>>> still trying to wrap my head around _all_ of DBIC, so I'm not just
>>> being pedantic. :-)
>> No. MyApp::Model::Foo isa C::M::DBIC::Schema
>>
>> If you had a Bar class in the relevant schema,
>>
>> MyApp->model('Foo::Bar') would give you a DBIx::Class::ResultSet though.
> 
> What if you want to access the ResultSource ?

MyApp->model('Foo::Bar')->result_source

as documented.

> Situation: I sometimes find that I need "create-logic" and I would
> really like to put it into the schema-definitions classes (ResultSource
> if I'm not wrong), but I cannot seem to get direct access to those from
> within Catalyst?

No, that's just a class. That would be

MyApp->model('Foo::Bar')->result_class

So yes you can, you just need to think about it a little bit :)

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list