Commit | Line | Data |
ba599d1c |
1 | package Catalyst::AttrContainer; |
2 | |
4cfa1efa |
3 | use Moose; |
6323fda2 |
4 | #use MooseX::ClassAttribute; |
ba599d1c |
5 | use Catalyst::Exception; |
6323fda2 |
6 | use Class::Data::Inheritable; |
7 | { |
8 | my $mk_classdata = Class::Data::Inheritable->can('mk_classdata'); |
9 | __PACKAGE__->meta->add_method(mk_classdata => $mk_classdata); |
10 | } |
ba599d1c |
11 | |
6323fda2 |
12 | __PACKAGE__->mk_classdata(_attr_cache => {}); |
13 | __PACKAGE__->mk_classdata(_action_cache => []); |
14 | |
15 | # class_has _attr_cache => ( |
16 | # is => 'rw', |
17 | # isa => 'HashRef', |
18 | # required => 1, |
19 | # default => sub{{}} |
20 | # ); |
21 | # class_has _action_cache => ( |
22 | # is => 'rw', |
23 | # isa => 'ArrayRef', |
24 | # required => 1, |
25 | # default => sub{ [] } |
26 | # ); |
ba599d1c |
27 | |
28 | # note - see attributes(3pm) |
29 | sub MODIFY_CODE_ATTRIBUTES { |
30 | my ( $class, $code, @attrs ) = @_; |
4cfa1efa |
31 | #can't the below just be $class->_attr_cache->{$code} = \@attrs; ? |
57e45928 |
32 | $class->_attr_cache( { %{ $class->_attr_cache }, $code => [@attrs] } ); |
4cfa1efa |
33 | #why can't this just be push @{$class->_action_cache}, [$code, \@attrs] ? |
57e45928 |
34 | $class->_action_cache( |
35 | [ @{ $class->_action_cache }, [ $code, [@attrs] ] ] ); |
ba599d1c |
36 | return (); |
37 | } |
38 | |
39 | sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () } |
40 | |
41 | =head1 NAME |
42 | |
43 | Catalyst::AttrContainer |
44 | |
45 | =head1 SYNOPSIS |
46 | |
47 | =head1 DESCRIPTION |
48 | |
4cfa1efa |
49 | This class sets up the code attribute cache. It's a base class for |
a1e61a69 |
50 | L<Catalyst::Controller>. |
649fd1fa |
51 | |
ba599d1c |
52 | =head1 METHODS |
53 | |
b5ecfcf0 |
54 | =head2 FETCH_CODE_ATTRIBUTES |
ba599d1c |
55 | |
649fd1fa |
56 | Attribute function. See attributes(3pm) |
57 | |
b5ecfcf0 |
58 | =head2 MODIFY_CODE_ATTRIBUTES |
ba599d1c |
59 | |
649fd1fa |
60 | Attribute function. See attributes(3pm) |
61 | |
ba599d1c |
62 | =head1 SEE ALSO |
63 | |
a1e61a69 |
64 | L<Catalyst::Dispatcher> |
ba599d1c |
65 | L<Catalyst>. |
66 | |
67 | =head1 AUTHOR |
68 | |
69 | Sebastian Riedel, C<sri@cpan.org> |
70 | Marcus Ramberg, C<mramberg@cpan.org> |
71 | |
72 | =head1 COPYRIGHT |
73 | |
74 | This program is free software, you can redistribute it and/or modify it under |
75 | the same terms as Perl itself. |
76 | |
77 | =cut |
78 | |
79 | 1; |