[Dbix-class] adding methods to result class

Brandon Black blblack at gmail.com
Thu Jan 4 17:31:18 GMT 2007


On 1/4/07, Tobias Kremer <t at funkreich.de> wrote:
> Zitat von Daniel McBrearty <danielmcbrearty at gmail.com>:
> > I want to add a new find method to one of my result classes ...
> > now what can I call 'find' on in this class? How can I get at the resultset?
>
> I suppose the correct way is to use the ResultSetManager component of
> DBIx::Class and tag your method as a ResultSet. You can then call this method
> on your ResultSet object. The POD has an example in thje Synopsis:
>
> http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/ResultSetManager.pm
>

As an alternative, you can also do the same thing manually without
ResultSetManager and the attribute, like:

Members.pm:
---------

package Engoi::Schema::EngoiDb::Members::ResultSet;
use base qw/DBIx::Class::ResultSet/;
sub find_by_name_or_email { .... }

package Engoi::Schema::EngoiDb::Members;
[ all of the normal code you pasted earlier ]
__PACKAGE__->resultset_class('Engoi::Schema::EngoiDb::Members::ResultSet');
1;



More information about the Dbix-class mailing list