Create branch register_actions.
[catagits/Catalyst-Runtime.git] / lib / Catalyst / AttrContainer.pm
1 package Catalyst::AttrContainer;
2
3 use Moose;
4 use Catalyst::Exception;
5 with 'Catalyst::ClassData';
6
7 no Moose;
8
9 __PACKAGE__->mk_classdata(_attr_cache => {} );
10 __PACKAGE__->mk_classdata( _action_cache => [] );
11
12 # note - see attributes(3pm)
13 sub MODIFY_CODE_ATTRIBUTES {
14     my ( $class, $code, @attrs ) = @_;
15     $class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } );
16     $class->_action_cache(
17         [ @{ $class->_action_cache }, [ $code, [@attrs] ] ] );
18     return ();
19 }
20
21 sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () }
22
23 =head1 NAME
24
25 Catalyst::AttrContainer - Handles code attribute storage and caching
26
27 =head1 SYNOPSIS
28
29 =head1 DESCRIPTION
30
31 This class sets up the code attribute cache.  It's a base class for 
32 L<Catalyst::Controller>.
33
34 =head1 METHODS
35
36 =head2 FETCH_CODE_ATTRIBUTES
37
38 Attribute function. See attributes(3pm)
39
40 =head2 MODIFY_CODE_ATTRIBUTES
41
42 Attribute function. See attributes(3pm)
43
44 =head1 SEE ALSO
45
46 L<Catalyst::Dispatcher>
47 L<Catalyst>.
48
49 =head1 AUTHORS
50
51 Catalyst Contributors, see Catalyst.pm
52
53 =head1 COPYRIGHT
54
55 This program is free software, you can redistribute it and/or modify it under
56 the same terms as Perl itself.
57
58 =cut
59
60 1;