Catalyst-Manual

 view release on metacpan or  search on metacpan

lib/Catalyst/Manual/Intro.pod  view on Meta::CPAN

Add a field to C<$c>, like C<my_model_instance>. Then write your
C<ACCEPT_CONTEXT> method to look like this:

    sub ACCEPT_CONTEXT {
      my ( $self, $c ) = @_;

      if ( my $per_request = $c->my_model_instance ) {
        return $per_request;
      } else {
        my $new_instance = bless { %$self, c => $c }, ref($self);
        Scalar::Util::weaken($new_instance->{c}); # or we have a circular reference
        $c->my_model_instance( $new_instance );
        return $new_instance;
      }
    }

For a similar technique to grab a new component instance on each
request, see L<Catalyst::Component::InstancePerContext>.

=head3 Application Class



( run in 0.393 second using v1.01-cache-2.11-cpan-65fba6d93b7 )