committing broken version. rolling back in a min. just making sure this gets saved...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / AttrContainer.pm
CommitLineData
ba599d1c 1package Catalyst::AttrContainer;
2
4cfa1efa 3use Moose;
6323fda2 4#use MooseX::ClassAttribute;
ba599d1c 5use Catalyst::Exception;
6323fda2 6use 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)
29sub 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
39sub FETCH_CODE_ATTRIBUTES { $_[0]->_attr_cache->{ $_[1] } || () }
40
41=head1 NAME
42
43Catalyst::AttrContainer
44
45=head1 SYNOPSIS
46
47=head1 DESCRIPTION
48
4cfa1efa 49This class sets up the code attribute cache. It's a base class for
a1e61a69 50L<Catalyst::Controller>.
649fd1fa 51
ba599d1c 52=head1 METHODS
53
b5ecfcf0 54=head2 FETCH_CODE_ATTRIBUTES
ba599d1c 55
649fd1fa 56Attribute function. See attributes(3pm)
57
b5ecfcf0 58=head2 MODIFY_CODE_ATTRIBUTES
ba599d1c 59
649fd1fa 60Attribute function. See attributes(3pm)
61
ba599d1c 62=head1 SEE ALSO
63
a1e61a69 64L<Catalyst::Dispatcher>
ba599d1c 65L<Catalyst>.
66
67=head1 AUTHOR
68
69Sebastian Riedel, C<sri@cpan.org>
70Marcus Ramberg, C<mramberg@cpan.org>
71
72=head1 COPYRIGHT
73
74This program is free software, you can redistribute it and/or modify it under
75the same terms as Perl itself.
76
77=cut
78
791;