bbdde3fe7b9e08fffb31705c6b567d1af666de78
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / LifeCycle / Request.pm
1 package Catalyst::IOC::LifeCycle::Request;
2 use Moose::Role;
3 use namespace::autoclean;
4 use Carp;
5 with 'Bread::Board::LifeCycle';
6 use Data::Dumper;
7
8 around get => sub {
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;
18
19     my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name;
20     return $ctx->stash->{$stash_key} ||= $self->$orig(@_);
21 };
22
23 1;
24
25 __END__
26
27 =pod
28
29 =head1 NAME
30
31 Catalyst::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
41 Catalyst Contributors, see Catalyst.pm
42
43 =head1 COPYRIGHT
44
45 This library is free software. You can redistribute it and/or modify it under
46 the same terms as Perl itself.
47
48 =cut