[Catalyst] Doing work inside the DBIx::Class model

Matt S Trout dbix-class at trout.me.uk
Sat Feb 23 19:28:07 GMT 2008


On Thu, Feb 21, 2008 at 01:59:40PM +1000, Cian Barclay wrote:
> >On Wed, Feb 20, 2008 at 4:33 PM, Zbigniew Lukasiak <zzbbyy at gmail.com>
> wrote:
> >
> >
> > He meant result_source:
> >
> http://cpan.uwinnipeg.ca/htdocs/DBIx-Class/DBIx/Class/ResultSet.html#result_source
> >
> >
> 
> Thanks Zbigniew and Toby, that's just what I needed to know. Is there
> a good way to call a class method and get a resultset to use?
> I'm using Widget::class_method($schema) to give it the schema
> from $self->result_source->schema. Is there a better way to do it?

Yes, don't write class methods in DBIC.

If the operation is on multiple rows, make it a resultset method.

If the operation is on a single row, make it a method on the row object.

If the operation is on a bunch of different things and neither of those
make sense, make it a method on the schema object.

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list