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