1 package Catalyst::AttrContainer;
4 #use MooseX::ClassAttribute;
5 use Catalyst::Exception;
6 use Class::Data::Inheritable;
8 my $mk_classdata = Class::Data::Inheritable->can('mk_classdata');
9 __PACKAGE__->meta->add_method(mk_classdata => $mk_classdata);
12 __PACKAGE__->mk_classdata(_attr_cache => {});
13 __PACKAGE__->mk_classdata(_action_cache => []);
15 # class_has _attr_cache => (
21 # class_has _action_cache => (
25 # default => sub{ [] }
28 # note - see attributes(3pm)
29 sub MODIFY_CODE_ATTRIBUTES {
30 my ( $class, $code, @attrs ) = @_;
31 #can't the below just be $class->_attr_cache->{$code} = \@attrs; ?
32 $class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } );
33 #why can't this just be push @{$class->_action_cache}, [$code, \@attrs] ?
34 $class->_action_cache(
35 [ @{ $class->_action_cache }, [ $code, [@attrs] ] ] );
39 sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () }
43 Catalyst::AttrContainer
49 This class sets up the code attribute cache. It's a base class for
50 L<Catalyst::Controller>.
54 =head2 FETCH_CODE_ATTRIBUTES
56 Attribute function. See attributes(3pm)
58 =head2 MODIFY_CODE_ATTRIBUTES
60 Attribute function. See attributes(3pm)
64 L<Catalyst::Dispatcher>
69 Sebastian Riedel, C<sri@cpan.org>
70 Marcus Ramberg, C<mramberg@cpan.org>
74 This program is free software, you can redistribute it and/or modify it under
75 the same terms as Perl itself.