Request - it's definitely not a Singleton, and it needs the context
[catagits/Catalyst-Runtime.git] / lib / Catalyst / IOC / LifeCycle / Request.pm
CommitLineData
2402ef14 1package Catalyst::IOC::LifeCycle::Request;
2use Moose::Role;
3use namespace::autoclean;
da87ad6a 4with 'Bread::Board::LifeCycle';
2402ef14 5
1a6941f5 6around get => sub {
7 my $orig = shift;
8 my $self = shift;
9
da87ad6a 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
1a6941f5 24 my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name;
da87ad6a 25 return $ctx->stash->{$stash_key} ||= $instance;
1a6941f5 26};
27
2402ef14 281;
64e06b7d 29
30__END__
31
32=pod
33
34=head1 NAME
35
36Catalyst::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
46Catalyst Contributors, see Catalyst.pm
47
48=head1 COPYRIGHT
49
50This library is free software. You can redistribute it and/or modify it under
51the same terms as Perl itself.
52
53=cut