[Dbix-class] Set a resultset_class for a result_class from within
a component loaded by the result_class
Jess Robinson
castaway at desert-island.me.uk
Sat Mar 14 10:44:29 GMT 2009
On Thu, 5 Mar 2009, kevin montuori wrote:
>>>>>> "PR" == Peter Rabbitson <rabbit+dbic at rabbit.us> writes:
>
>
> >> You put ResultSetManager in your load_components and you put your custom
> >> plugin for resultset into a load_resultset_components call. An example
> >> from one of my classes.
>
> PR> Isn't ResultSetManager deprecated to the point of removal?
>
> it's tagged "experimental" but not deprecated. i hope it's not going
> away, i get a lot of use out of it.
It is going away. Since you can replace it with very few lines of code, it
doesnt have much reason for existance.
Instead of writing:
sub mymethod : ResultSet { .. }
write:
__PACKAGE__->resultset_class('My::ResultSet');
And later:
package My::ResultSet;
use base 'DBIx::Class::ResultSet';
sub mymethod { .. }
1;
You can even have that bit at the bottom of your result class, if you dont
want to create a new one.
Current best practice suggests you create a new class, have your schema
laid out as:
Schema/Result/Books.pm
Schema/ResultSet/Books.pm
and use load_namespaces, in Schema.pm
See docs ;)
Jess
More information about the DBIx-Class
mailing list