[Catalyst] Catalyst::Model::Adaptor - because models shouldn't *do* anything

Jonathan Rockway jon at jrock.us
Tue Oct 9 20:16:21 GMT 2007

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.

So, adding anything to Model::Adaptor or a subclass of it would be
pointless, since there's no way you can get at those methods.  (You
could get them at COMPONENT time, but not after that.)

Let me know if this is what you were talking about.

Jonathan Rockway

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 370 bytes
Desc: OpenPGP digital signature
Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071009/3ad4=

More information about the Catalyst mailing list