X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FController.pm;h=16b7fb41d9e35e0c95b15765cc1f4d51ab96ea75;hb=95b3daedb0643a8983db288fe35faa43c56b9294;hp=e821a46cae63228c221883818e2269534a92ab45;hpb=bc6779694182f9c5b08665b6624693612db5ea91;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index e821a46..16b7fb4 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -1,7 +1,7 @@ package Catalyst::Controller; use Moose; -use Moose::Util qw/find_meta does_role/; +use Moose::Util qw/find_meta/; use namespace::clean -except => 'meta'; @@ -174,15 +174,26 @@ around path_prefix => sub { return $namespace; }; +sub get_action_methods { + my $self = shift; + my $meta = find_meta($self); + 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; + return @methods; +} sub register_actions { my ( $self, $c ) = @_; + $self->register_action_methods( $c, $self->get_action_methods ); +} + +sub register_action_methods { + my ( $self, $c, @methods ) = @_; my $class = ref $self || $self; #this is still not correct for some reason. my $namespace = $self->action_namespace($c); - my $meta = find_meta($self); - my @methods = grep { does_role($_, 'MooseX::MethodAttributes::Role::Meta::Method') } - $meta->get_all_methods; foreach my $method (@methods) { my $name = $method->name;