X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController.pm;h=a080f8438cb3a007c496c3a5c88e38a23a1f2659;hb=56e19078d7169c3c969468f8730d48e12271adb6;hp=18c825968deb622fdadddf5e6f947652658e80ca;hpb=ae29b412955743885e80350085167b54b69672da;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 18c8259..a080f84 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -5,8 +5,7 @@ use Moose::Util qw/find_meta/; use namespace::clean -except => 'meta'; -# Note - Must be done at compile time due to attributes (::AttrContainer) -BEGIN { extends qw/Catalyst::Component Catalyst::AttrContainer/; } +BEGIN { extends qw/Catalyst::Component MooseX::MethodAttributes::Inheritable/; } use Catalyst::Exception; use Catalyst::Utils; @@ -182,34 +181,27 @@ sub register_actions { #this is still not correct for some reason. my $namespace = $self->action_namespace($c); my $meta = find_meta($self); - my %methods = map { $_->body => $_->name } - $meta->get_all_methods; - - # Advanced inheritance support for plugins and the like - #moose todo: migrate to eliminate CDI compat - my @action_cache; - for my $isa ( $meta->superclasses, $class ) { - if(my $coderef = $isa->can('_action_cache')){ - push(@action_cache, @{ $isa->$coderef }); - } - } - - foreach my $cache (@action_cache) { - my $code = $cache->[0]; - my $method = delete $methods{$code}; # avoid dupe registers - next unless $method; - my $attrs = $self->_parse_attrs( $c, $method, @{ $cache->[1] } ); + confess("Metaclass for " . ref($meta) ." for " . $meta->name + . " cannot support register_actions.") + unless $meta->can('get_all_methods_with_attributes'); + my @methods = $meta->get_all_methods_with_attributes; + + foreach my $method (@methods) { + my $name = $method->name; + my $attributes = $method->attributes; + next unless $attributes; + my $attrs = $self->_parse_attrs( $c, $name, @{ $attributes } ); if ( $attrs->{Private} && ( keys %$attrs > 1 ) ) { $c->log->debug( 'Bad action definition "' - . join( ' ', @{ $cache->[1] } ) - . qq/" for "$class->$method"/ ) + . join( ' ', @{ $attributes } ) + . qq/" for "$class->$name"/ ) if $c->debug; next; } - my $reverse = $namespace ? "${namespace}/${method}" : $method; + my $reverse = $namespace ? "${namespace}/${name}" : $name; my $action = $self->create_action( - name => $method, - code => $code, + name => $name, + code => $method->body, reverse => $reverse, namespace => $namespace, class => $class,