Catalyst::Model::Role::RunAfterRequest - run code after the response has been sent


Catalyst-Plugin-RunAfterRequest documentation Contained in the Catalyst-Plugin-RunAfterRequest distribution.

Index


Code Index:

NAME

Top

Catalyst::Model::Role::RunAfterRequest - run code after the response has been sent

DESCRIPTION

Top

See Catalyst::Plugin::RunAfterRequest for full documentation.

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


Catalyst-Plugin-RunAfterRequest documentation Contained in the Catalyst-Plugin-RunAfterRequest distribution.

package Catalyst::Model::Role::RunAfterRequest;
BEGIN {
  $Catalyst::Model::Role::RunAfterRequest::AUTHORITY = 'cpan:FLORA';
}
BEGIN {
  $Catalyst::Model::Role::RunAfterRequest::VERSION = '0.04';
}
# ABSTRACT: run code after the response has been sent

use Moose::Role;
use Catalyst::Component::InstancePerContext;

with 'Catalyst::Component::InstancePerContext';

has '_context' => ( is => 'ro', weak_ref => 1 );

# no-op that the 'around' can wrap. Allows the higher up model to implement
# their own 'build_per_context_instance' method.
sub build_per_context_instance { return shift; }

around build_per_context_instance => sub {
    my $orig = shift;
    my $self = shift;
    my $c    = shift;

    $self = $self->$orig( $c, @_ );

    bless( { %$self, _context => $c }, ref($self) );
};

sub _run_after_request {
    my $self = shift;
    $self->_context->run_after_request(@_);
}


1;

__END__