Commit | Line | Data |
2402ef14 |
1 | package Catalyst::IOC::LifeCycle::Request; |
2 | use Moose::Role; |
3 | use namespace::autoclean; |
3bb9642f |
4 | use Carp; |
da87ad6a |
5 | with 'Bread::Board::LifeCycle'; |
287df7b2 |
6 | use Data::Dumper; |
2402ef14 |
7 | |
1a6941f5 |
8 | around 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 |
23 | 1; |
64e06b7d |
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 |