Christopher H. Laco wrote:
Personally, I almost always do:

sub COMPONENT {
   my $self = NEXT::new

 diddle config...return $self
}


Sorry...that pseudo code was too vague:


sub COMPONENT {
  my $self = shift->NEW::new(@_);
  $self->{'noncatclass'} = NonCatClass->new
  return $self
}

Then, delegate via autoload, or use real methods to forward request to
the instance of the real class...

I assume you mean:

my $self = shift->NEXT::new(@_);

in which case it fails with:

Can't call NEXT::new from MyApp::Model::Widget::COMPONENT

I noticed that a number of newer models on CPAN were using this construction:

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?

--
Jamie Neil | <[EMAIL PROTECTED]> | 0870 7777 454
Versado I.T. Services Ltd. | http://versado.net/ | 0845 450 1254

_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to