Unfuck last commit, fix go tests, remove unneeded crud from TestApp, add FIXME for...
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Dispatcher.pm
index 865dd2f..2786b2e 100644 (file)
@@ -190,7 +190,7 @@ sub _do_visit {
     }
     elsif (!defined $action->namespace) {
         $error .= qq/Action has no namespace: cannot $opname() to a plain /
-                 .qq/method or component, must be a :Action or some sort./
+                 .qq/method or component, must be an :Action of some sort./
     }
     elsif (!$action->class->can('_DISPATCH')) {
         $error .= qq/Action cannot _DISPATCH. /
@@ -318,8 +318,16 @@ sub _find_component_class {
 sub _invoke_as_component {
     my ( $self, $c, $component, $method ) = @_;
 
+    #FIXME - Is this resolving needed/should it just return the instance
+    #        directly
     my $class = $self->_find_component_class( $c, $component ) || return 0;
 
+    my $component_instance = $c->component($class);
+    if (my $code = $component_instance->can('action_for')) {
+        my $possible_action = $component_instance->$code($method);
+        return $possible_action if $possible_action;
+    }
+
     if ( my $code = $class->can($method) ) {
         return $self->_method_action_class->new(
             {