35741e420726ffc9d526bab8ce688d9b92f497d0
[catagits/Catalyst-Runtime.git] / lib / Catalyst / AttrContainer.pm
1 package Catalyst::AttrContainer;
2
3 use strict;
4 use base qw/Class::Data::Inheritable Class::Accessor::Fast/;
5
6 use Catalyst::Exception;
7 use NEXT;
8
9 __PACKAGE__->mk_classdata($_) for qw/_attr_cache _action_cache/;
10 __PACKAGE__->_attr_cache( {} );
11 __PACKAGE__->_action_cache( [] );
12
13 # note - see attributes(3pm)
14 sub MODIFY_CODE_ATTRIBUTES {
15     my ( $class, $code, @attrs ) = @_;
16     $class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } );
17     $class->_action_cache(
18         [ @{ $class->_action_cache }, [ $code, [@attrs] ] ] );
19     return ();
20 }
21
22 sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () }
23
24 =head1 NAME
25
26 Catalyst::AttrContainer
27
28 =head1 SYNOPSIS
29
30 =head1 DESCRIPTION
31
32 =head1 METHODS
33
34 =over 4
35
36 =item FETCH_CODE_ATTRIBUTES
37
38 =item MODIFY_CODE_ATTRIBUTES
39
40 =back
41
42 =head1 SEE ALSO
43
44 L<Catalyst>.
45
46 =head1 AUTHOR
47
48 Sebastian Riedel, C<sri@cpan.org>
49 Marcus Ramberg, C<mramberg@cpan.org>
50
51 =head1 COPYRIGHT
52
53 This program is free software, you can redistribute it and/or modify it under
54 the same terms as Perl itself.
55
56 =cut
57
58 1;