Commit | Line | Data |
2402ef14 |
1 | package Catalyst::IOC::LifeCycle::Request; |
2 | use Moose::Role; |
3 | use namespace::autoclean; |
da87ad6a |
4 | with 'Bread::Board::LifeCycle'; |
2402ef14 |
5 | |
1a6941f5 |
6 | around get => sub { |
287df7b2 |
7 | my $orig = shift; |
8 | my $self = shift; |
9 | my $params = {@_}; |
10 | |
11 | my $ctx = exists $params->{ctx} && ref $params->{ctx} |
12 | ? $params->{ctx} |
13 | : undef |
14 | ; |
e6392b94 |
15 | |
16 | # FIXME - this makes absolutely no sense |
17 | # dispatcher wants the object (through container->get_all_components) |
18 | # but doesn't have the context. Builder *needs* the context!! |
19 | # What to do??? |
287df7b2 |
20 | return $self->$orig(@_) unless $ctx; |
da87ad6a |
21 | |
1a6941f5 |
22 | my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name; |
2c77a894 |
23 | return $ctx->stash->{$stash_key} ||= $self->$orig(@_); |
1a6941f5 |
24 | }; |
25 | |
2402ef14 |
26 | 1; |
64e06b7d |
27 | |
28 | __END__ |
29 | |
30 | =pod |
31 | |
32 | =head1 NAME |
33 | |
34 | Catalyst::IOC::LifeCycle::Request - Components that last for one request |
35 | |
36 | =head1 SYNOPSIS |
37 | |
38 | =head1 DESCRIPTION |
39 | |
40 | =head1 METHODS |
41 | |
42 | =head1 AUTHORS |
43 | |
44 | Catalyst Contributors, see Catalyst.pm |
45 | |
46 | =head1 COPYRIGHT |
47 | |
48 | This library is free software. You can redistribute it and/or modify it under |
49 | the same terms as Perl itself. |
50 | |
51 | =cut |