fixed bug with under block leaking its setting to following actions
[catagits/CatalystX-Declare.git] / lib / CatalystX / Declare / Controller / RegisterActionRoles.pm
1 use MooseX::Declare;
2 use Class::MOP;
3
4 role CatalystX::Declare::Controller::RegisterActionRoles 
5     with CatalystX::Declare::Controller::QualifyClassNames {
6
7     around create_action (%args) {
8
9         my @action_roles = @{ delete($args{attributes}{CatalystX_Declarative_ActionRoles}) || [] };
10
11         my $action = $self->$orig(%args);
12
13         for my $role (@action_roles) {
14             my $fq_role = $self->_qualify_class_name(ActionRole => $role);
15
16             Class::MOP::load_class($fq_role);
17             $fq_role->meta->apply($action);
18         }
19
20         return $action;
21     }
22 }
23
24 1;