From: Tomas Doran Date: Mon, 7 Sep 2009 20:25:53 +0000 (+0000) Subject: AGH. Too tired to be doing this, fucked it up again X-Git-Tag: 5.80012~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=b138a0d00132d79ae4a1520e7aaeaf894c3bdd57 AGH. Too tired to be doing this, fucked it up again --- diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 3bdacec..cb01c11 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,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 @methods; } diff --git a/t/unit_controller_actions.t b/t/unit_controller_actions.t index 3ca705f..26e603d 100644 --- a/t/unit_controller_actions.t +++ b/t/unit_controller_actions.t @@ -22,5 +22,5 @@ my $controller = TestController->new($app, {actions => { foo => { Path => '/some ok $controller->can('_controller_actions'); is_deeply $controller->_controller_actions => { foo => { Path => '/some/path' }}; is_deeply $controller->{actions} => { foo => { Path => '/some/path' }}; # Back compat. -is_deeply [ sort grep { ! /^_/ } $controller->get_action_methods ], [sort qw/action foo/]; +is_deeply [ sort grep { ! /^_/ } map { $_->name } $controller->get_action_methods ], [sort qw/action foo/];