X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController.pm;h=d52ae3f8dbdf488d1591549ac6431cc327fe7e1c;hb=0da2dc3044ed62182fd3cf515b26c852edaa11b4;hp=b6ca882aab90585eccc988622335613ede71199e;hpb=df960201c8d8c22edddedced4471c14606877145;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index b6ca882..d52ae3f 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -29,9 +29,9 @@ has action_namespace => predicate => 'has_action_namespace', ); -has _controller_actions => +has actions => ( - is => 'rw', + accessor => '_controller_actions', isa => 'HashRef', init_arg => undef, ); @@ -187,20 +187,23 @@ sub get_action_methods { . $meta->name . " cannot support register_actions." ) unless $meta->can('get_nearest_methods_with_attributes'); - my @methods = $meta->get_nearest_methods_with_attributes; - # actions specified via config are also action_methods - push( - @methods, - map { + # Find (and de-dup) action methods from attributes and those from config. + my %methods = ( + map({ $_->name => 1 } $meta->get_nearest_methods_with_attributes), + %{ $self->_controller_actions } + ); + + if (ref $self) { + foreach (keys %methods) { $meta->find_method_by_name($_) || confess( 'Action "' . $_ . '" is not available from controller ' - . ( ref $self ) ) - } keys %{ $self->_controller_actions } - ) if ( ref $self ); - return @methods; + . ( ref $self ) ); + } + } + return keys %methods; }