X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController.pm;h=dc68a33ed5e09100333edcae76ddfda1fe50ab32;hb=4f4ab5b4e0f1cf9a41e019f52067e968764ee7f4;hp=3bdacecf2aa1358f7990b5be8e283e5c2a4aa1c8;hpb=be38a59bd128d369353ef13972251bc379afae57;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 3bdacec..dc68a33 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -2,7 +2,7 @@ package Catalyst::Controller; use Moose; use Moose::Util qw/find_meta/; - +use List::MoreUtils qw/uniq/; use namespace::clean -except => 'meta'; BEGIN { extends qw/Catalyst::Component MooseX::MethodAttributes::Inheritable/; } @@ -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,23 +187,20 @@ 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; - # 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) { + # actions specified via config are also action_methods + push( + @methods, + map { $meta->find_method_by_name($_) || confess( 'Action "' . $_ . '" is not available from controller ' - . ( ref $self ) ); - } - } - return keys %methods; + . ( ref $self ) ) + } keys %{ $self->_controller_actions } + ) if ( ref $self ); + return uniq @methods; }