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'; |
2402ef14 |
6 | |
1a6941f5 |
7 | around get => sub { |
8 | my $orig = shift; |
9 | my $self = shift; |
10 | |
da87ad6a |
11 | my $instance = $self->$orig(@_); |
12 | |
da87ad6a |
13 | my $ctx = $self->param('ctx') |
3bb9642f |
14 | or confess qq/This component has a Request lifecycle.\n/ . |
15 | qq/The 'ctx' parameter is mandatory./; |
da87ad6a |
16 | |
1a6941f5 |
17 | my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name; |
da87ad6a |
18 | return $ctx->stash->{$stash_key} ||= $instance; |
1a6941f5 |
19 | }; |
20 | |
2402ef14 |
21 | 1; |
64e06b7d |
22 | |
23 | __END__ |
24 | |
25 | =pod |
26 | |
27 | =head1 NAME |
28 | |
29 | Catalyst::IOC::LifeCycle::Request - Components that last for one request |
30 | |
31 | =head1 SYNOPSIS |
32 | |
33 | =head1 DESCRIPTION |
34 | |
35 | =head1 METHODS |
36 | |
37 | =head1 AUTHORS |
38 | |
39 | Catalyst Contributors, see Catalyst.pm |
40 | |
41 | =head1 COPYRIGHT |
42 | |
43 | This library is free software. You can redistribute it and/or modify it under |
44 | the same terms as Perl itself. |
45 | |
46 | =cut |