Added support for non C::Base components to live in MyApp namespace
[catagits/Catalyst-Runtime.git] / lib / Catalyst / Dispatcher.pm
index 861d5ef..33d497f 100644 (file)
@@ -135,13 +135,22 @@ sub forward {
 
     unless ( @{$results} ) {
         my $class = $command || '';
+        my $path  = $class . '.pm';
+        $path =~ s/::/\//g;
 
-        if ( $class =~ /[^\w\:]/ ) {
-            my $error = qq/Couldn't forward to "$class"/;
+        unless ( $INC{ $path } ) {
+            my $error = qq/Couldn't forward to "$class". Invalid or not loaded./;
             $c->error($error);
             $c->log->debug($error) if $c->debug;
             return 0;
         }
+        
+        unless ( UNIVERSAL::isa( $class, 'Catalyst::Base' ) ) {
+            my $error = qq/Can't forward to "$class". Class is not a Catalyst component./;
+            $c->error($error);
+            $c->log->debug($error) if $c->debug;
+            return 0;            
+        }
 
         my $method = shift || 'process';
 
@@ -151,7 +160,7 @@ sub forward {
         }
 
         else {
-            my $error = qq/Couldn't forward to "$class"/;
+            my $error = qq/Couldn't forward to "$class". Does not implement "$method"/;
             $c->error($error);
             $c->log->debug($error)
               if $c->debug;
@@ -235,13 +244,7 @@ sub get_action {
             my $name  = $c->actions->{compiled}->[$i]->[0];
             my $regex = $c->actions->{compiled}->[$i]->[1];
 
-            if ( $action =~ $regex ) {
-                my @snippets;
-                for my $i ( 1 .. 9 ) {
-                    no strict 'refs';
-                    last unless ${$i};
-                    push @snippets, ${$i};
-                }
+            if ( my @snippets = ( $action =~ $regex ) ) {
                 return [ [ $c->actions->{regex}->{$name}, $name, \@snippets ] ];
             }