[Catalyst] subclassing model classes

Wallace Reis wallace at reis.org.br
Tue Dec 15 12:58:56 GMT 2009


On 15/12/2009, at 08:32, matthew couchman (JIC) wrote:
> Hi,

Hi!
Are you using DBIx::Class, right? So, note that DBIC is a separate project and has its own ML (http://lists.scsys.co.uk/mailman/listinfo/dbix-class/).

> I’m trying to subclass a model class so that when I search it only pulls out rows of a certain type. I thought that perhaps I could achieve that by overriding the search() function and adding a condition to the list of arguments as below:
> I don’t think that my new search function is ever called though. Do I need to override anything else or am I just barking up the wrong tree completely?

You want to extend a resultset class with a custom method like:

package MyApp::Schema::ResultSet::Point;

use base 'DBIx::Class::ResultSet';

sub vertex {
    my $rs = shift;
    return $rs->search({ type => 'vertex' });
}

1;

--
   wallace reis/wreis         Catalyst and DBIx::Class consultancy with a clue
   Software Engineer          and a commit bit: http://shadowcat.co.uk/catalyst/
Shadowcat Systems Limited
http://www.shadowcat.co.uk     http://www.linkedin.com/in/wallacereis




More information about the Catalyst mailing list