X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FIOC%2FLifeCycle%2FRequest.pm;h=39468d7957e4fb53f4f707c81dea8d1d3fa9fc3d;hb=cdd4485fd83d88cd2f68a2d9a5685fe4f3c33864;hp=f350e3a008a30ead4e7065a82d4a2959f1520c38;hpb=2402ef14c70916ab2c5f3aaac8739217e1ab610a;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/IOC/LifeCycle/Request.pm b/lib/Catalyst/IOC/LifeCycle/Request.pm index f350e3a..39468d7 100644 --- a/lib/Catalyst/IOC/LifeCycle/Request.pm +++ b/lib/Catalyst/IOC/LifeCycle/Request.pm @@ -1,10 +1,46 @@ package Catalyst::IOC::LifeCycle::Request; use Moose::Role; use namespace::autoclean; +use Carp; +with 'Bread::Board::LifeCycle'; -# based on Bread::Board::LifeCycle::Request from OX -# just behaves like a singleton - ::Request instances -# will get flushed after the response is sent -with 'Bread::Board::LifeCycle::Singleton'; +around get => sub { + my $orig = shift; + my $self = shift; + + # FIXME - ugly, but the only way it'll work + # we should find out why + my $ctx = {@_}->{'ctx'} + or confess qq/This component has a Request lifecycle.\n/ . + qq/The 'ctx' parameter is mandatory./; + + my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name; + return $ctx->stash->{$stash_key} ||= $self->$orig(@_); +}; 1; + +__END__ + +=pod + +=head1 NAME + +Catalyst::IOC::LifeCycle::Request - Components that last for one request + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 METHODS + +=head1 AUTHORS + +Catalyst Contributors, see Catalyst.pm + +=head1 COPYRIGHT + +This library is free software. You can redistribute it and/or modify it under +the same terms as Perl itself. + +=cut