removed FIXME, added confess()
[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 use Carp;
5 with 'Bread::Board::LifeCycle';
6
7 around get => sub {
8     my $orig = shift;
9     my $self = shift;
10
11     my $instance = $self->$orig(@_);
12
13     my $ctx = $self->param('ctx')
14         or confess qq/This component has a Request lifecycle.\n/ .
15                    qq/The 'ctx' parameter is mandatory./;
16
17     my $stash_key = "__Catalyst_IOC_LifeCycle_Request_" . $self->name;
18     return $ctx->stash->{$stash_key} ||= $instance;
19 };
20
21 1;
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