[Catalyst] Catalyst::Model::Adaptor - because models shouldn't
*do* anything
Christopher H. Laco
claco at chrislaco.com
Wed Oct 10 15:18:52 GMT 2007
John Napiorkowski wrote:
> --- Jonathan Rockway <jon at jrock.us> wrote:
> =
>> John Napiorkowski wrote:
>>> One thing that I've done a lot with these kinds of
>>> adapters is use AUTOLOAD or use Moose's built in
>>> attribute delegation to make calling the adapted
>>> classes methods easier. Would you take a patch
>> for
>>> something like this and how might you envision it
>>> working. As a plugin, for example?
>>> =
>> If your model is:
>>
>> package MyApp::Model::Foo;
>> use base 'Catalyst::Model::Adaptor';
>> __PACKAGE__->config( class =3D> 'YourClass' );
>>
>> Then, in
>>
>> my $yourclass =3D $c->model('Foo')
>>
>> ref $yourclass is YourClass, not MyApp::Model::Foo. =
>> Whatever
>> YourClass->new returns is what $c->model returns.
Well, there is a downside to that. If I needed to override
YourClass->method to do something specific when it's running in Catalyst
as a model, then I have to create yet a third subclass:
MyApp::Model::Foo isa CatalystYourClass isa YourClass
instead of just overriding MyApp::Model::FOO->method
Personally, I prefer the latter and AUTOLOAD. If you hate autoload, you
can always map the methods dynamically.
-=3DChris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 187 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071010/b2df=
653b/signature.pgp
More information about the Catalyst
mailing list