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