some playing
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / LifeCycle / Request.pm
CommitLineData
2402ef14 1package Catalyst::IOC::LifeCycle::Request;
2use Moose::Role;
3use namespace::autoclean;
3bb9642f 4use Carp;
da87ad6a 5with 'Bread::Board::LifeCycle';
287df7b2 6use Data::Dumper;
2402ef14 7
1a6941f5 8around get => sub {
287df7b2 9 my $orig = shift;
10 my $self = shift;
11 my $params = {@_};
12
13 my $ctx = exists $params->{ctx} && ref $params->{ctx}
14 ? $params->{ctx}
15 : undef
16 ;
17 return $self->$orig(@_) unless $ctx;
da87ad6a 18
1a6941f5 19 my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name;
2c77a894 20 return $ctx->stash->{$stash_key} ||= $self->$orig(@_);
1a6941f5 21};
22
2402ef14 231;
64e06b7d 24
25__END__
26
27=pod
28
29=head1 NAME
30
31Catalyst::IOC::LifeCycle::Request - Components that last for one request
32
33=head1 SYNOPSIS
34
35=head1 DESCRIPTION
36
37=head1 METHODS
38
39=head1 AUTHORS
40
41Catalyst Contributors, see Catalyst.pm
42
43=head1 COPYRIGHT
44
45This library is free software. You can redistribute it and/or modify it under
46the same terms as Perl itself.
47
48=cut