3b277daf6466c7efb4198500d6f3262bb62d3f1b
[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 with 'Bread::Board::LifeCycle';
5
6 around get => sub {
7     my $orig = shift;
8     my $self = shift;
9
10     my $instance = $self->$orig(@_);
11
12 # FIXME -
13 # during setup in Catalyst.pm:
14 #  - $class->setup_actions (line 3025)
15 #      - $c->dispatcher->setup_actions (line 2271)
16 #          - $c->components in Catalyst/Dispatcher.pm line 604
17 # which boils down to line 616 in Catalyst/IOC/Container.pm
18 # resolving the component _without_ the 'context' parameter.
19 # Should it get the context parameter? Should all calls to a
20 # ConstructorInjection service pass that parameter?
21     my $ctx = $self->param('ctx')
22         or return $instance;
23
24     my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name;
25     return $ctx->stash->{$stash_key} ||= $instance;
26 };
27
28 1;
29
30 __END__
31
32 =pod
33
34 =head1 NAME
35
36 Catalyst::IOC::LifeCycle::Request - Components that last for one request
37
38 =head1 SYNOPSIS
39
40 =head1 DESCRIPTION
41
42 =head1 METHODS
43
44 =head1 AUTHORS
45
46 Catalyst Contributors, see Catalyst.pm
47
48 =head1 COPYRIGHT
49
50 This library is free software. You can redistribute it and/or modify it under
51 the same terms as Perl itself.
52
53 =cut