[Catalyst] Creating a thin Model
Jamie Neil
jamie at versado.net
Mon May 21 12:31:22 GMT 2007
Matt S Trout wrote:
>> use base qw/ Catalyst::Model /;
>>
>> sub new {
>> my $self = shift->next::method(@_);
>> my $class = ref($self);
>> my ( $c, $args ) = @_;
>> $self->{'.mymodel'} = ExternalModule->new(
>> Catalyst::Utils::merge_hashes( $args, $self->config )
>> );
>> return $self;
>> }
>>
>> sub ACCEPT_CONTEXT {
>> return shift->{'.mymodel'};
>> }
>>
>> or is this only recommended if you need to make the context available in
>> the external module?
>
> No, that's just plain silly. Could I have a list of the models that do that
> so I can track down the authors and slap them, please?
http://search.cpan.org/search?query=catalyst%3A%3Amodel+accept_context
brings up most of them, but there are a few more like Net::Amazon.
> sub new {
> my ($class, $c, $args) = @_;
> return ExternalModule->new(
> Catalyst::Utils::merge_hashes( $args, $class->config )
> );
> }
Thanks, I'll give that a try.
--
Jamie Neil | <jamie at versado.net> | 0870 7777 454
Versado I.T. Services Ltd. | http://versado.net/ | 0845 450 1254
More information about the Catalyst
mailing list