It is not clear from your code sample,
but your __PACKAGE__->table_class call has to occur before
__PACKAGE__->table call, otherwise it has no effect.

Roman


2011/9/22 Lyle Kopnicky <[email protected]>:
> On Wed, Sep 14, 2011 at 11:28 AM, Alexander Hartmaier
> <[email protected]> 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 class:
>> __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 = My::Schema->connect(...);
> my $source = $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 | [email protected]
> RENTRAK | www.rentrak.com | NASDAQ: RENT
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/[email protected]
>

_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]

Reply via email to