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