[Dbix-class] custom resultsource and subclasses
lerickson at rdwarf.net
Mon Jun 2 21:29:30 GMT 2014
On May 28, 2014, at 3:43 PM, Mitchell Elutovich <melutovich at gmail.com> wrote:
> Louis Erickson:
> >You mean like DBIx::Class::DynamicSubclass? The only odd part is the union of sql select, which sounds like a view to me.
> I'll have to think about the possibility of just using a view instead of a resultsource.
> Yes I've used DynamicSubclass in which it is described (in the Cookbook.pod#Dynamic_Sub-classing_DBIx::Class_proxy_classes) as:
> |DBIx::Class classes are proxy classes, therefore some different techniques need to be employed for more than basic subclassing. In this example we have a single user table that carries a boolean bit for |admin. We would like to give the admin users objects (DBIx::Class::Row) the same methods as a regular user but also special admin only methods. It doesn't make sense to create two separate proxy-class |files for this. We would be copying all the user methods into the Admin class. There is a cleaner way to accomplish this.
You could also put all the user methods in a Role and use it in both places.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the DBIx-Class