[Dbix-class] Re: Get table name from ResultSet class?
Lyle Kopnicky
lwk at rentrak.com
Wed Sep 21 22:22:16 GMT 2011
On Wed, Sep 14, 2011 at 11:28 AM, Alexander Hartmaier <
alexander.hartmaier at t-systems.at> wrote:
> Because the method foo is a method of the result (row) class and not the
> resultsource class.
> If you want to add resultsource methods you need to write a
> ResultSource::Table (or ::View) subclass and assign it to your result cla=
ss:
> __PACKAGE__->table_class('Your::Model::ResultSource::WithFooMethod');
>
> Thanks, but this does not seem to work. I set the table_class on the
Result class as you said, but then when I get the ResultSource class, it
doesn't have the methods I defined:
package My::Schema::ResultSource::MyTable;
use Moose;
extends 'DBIx::Class::ResultSource::Table';
sub foo { ... }
1;
package My::Schema::Result::MyTable;
...
__PACKAGE->table_class('My::Schema::ResultSource::MyTable');
1;
my $schema =3D My::Schema->connect(...);
my $source =3D $schema->source('MyTable');
$source->foo(...);
Blows up because foo is not found. In fact, the $source object is of class
My::Schema::ResultSource::Table, not my custom class.
-- =
Lyle Kopnicky | Software Developer
503.284.7581 x260 | lwk at rentrak.com <axc at rentrak.com>
RENTRAK | www.rentrak.com | NASDAQ: RENT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20110921/5d0=
788d3/attachment.htm
More information about the DBIx-Class
mailing list