I still haven't gotten this :)
[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     my $params = {@_};
10
11     my $ctx = exists $params->{ctx} && ref $params->{ctx}
12             ? $params->{ctx}
13             : undef
14             ;
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???
20     return $self->$orig(@_) unless $ctx;
21
22     my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name;
23     return $ctx->stash->{$stash_key} ||= $self->$orig(@_);
24 };
25
26 1;
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