dae87dc12e21a30d2d142ea143f0e2ec2ec088d8
[catagits/Catalyst-Runtime.git] / lib / Catalyst / AttrContainer.pm
1 package Catalyst::AttrContainer;
2
3 use Moose;
4 use MooseX::ClassAttribute;
5 use Catalyst::Exception;
6
7 class_has _attr_cache   => (
8                             is => 'rw',
9                             isa => 'HashRef',
10                             required => 1,
11                             default => sub{{}}
12                            );
13 clas_has _action_cache => (
14                            is => 'rw',
15                            isa => 'ArrayRef',
16                            required => 1,
17                            default => sub{ [] }
18                           );
19
20 # note - see attributes(3pm)
21 sub MODIFY_CODE_ATTRIBUTES {
22     my ( $class, $code, @attrs ) = @_;
23     #can't the below just be $class->_attr_cache->{$code} = \@attrs; ?
24     $class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } );
25     #why can't this just be push @{$class->_action_cache}, [$code, \@attrs] ?
26     $class->_action_cache(
27         [ @{ $class->_action_cache }, [ $code, [@attrs] ] ] );
28     return ();
29 }
30
31 sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () }
32
33 =head1 NAME
34
35 Catalyst::AttrContainer
36
37 =head1 SYNOPSIS
38
39 =head1 DESCRIPTION
40
41 This class sets up the code attribute cache.  It's a base class for
42 L<Catalyst::Controller>.
43
44 =head1 METHODS
45
46 =head2 FETCH_CODE_ATTRIBUTES
47
48 Attribute function. See attributes(3pm)
49
50 =head2 MODIFY_CODE_ATTRIBUTES
51
52 Attribute function. See attributes(3pm)
53
54 =head1 SEE ALSO
55
56 L<Catalyst::Dispatcher>
57 L<Catalyst>.
58
59 =head1 AUTHOR
60
61 Sebastian Riedel, C<sri@cpan.org>
62 Marcus Ramberg, C<mramberg@cpan.org>
63
64 =head1 COPYRIGHT
65
66 This program is free software, you can redistribute it and/or modify it under
67 the same terms as Perl itself.
68
69 =cut
70
71 1;