[Catalyst] Using C::DBI::Loader::Relationship with Model::CDBI?

Sebastian Riedel sri at oook.de
Wed Apr 6 00:08:05 CEST 2005


Am 06.04.2005 um 00:00 schrieb Andy Grundman:

> Sebastian Riedel wrote:
>> try
>>     use NEXT;
>>     sub new {
>>         my $class = shift;
>>         my $self    = $class->NEXT::new(@_);
>>         $self->loader->relationship(...);
>>         return $self;
>>     }
>
> Nice, this works!  But I don't really understand why it does.  The 
> Relationship class just adds a relationship() method to 
> Class::DBI::Loader::Generic's namespace.  I guess the object getting 
> set in loader() was created before Relationship was added, or 
> something like that?

The magic line is "my $self    = $class->NEXT::new(@_);", because 
loader gets initialized in the new method of our SUPER class...

> FYI I didn't need 'use NEXT;' for whatever reason.

Right, it's already used in Catalyst::Base...

--
sebastian




More information about the Catalyst mailing list