[Bps-public-commit] r16565 - in Prophet/branches/class-dispatch: .

sartak at bestpractical.com sartak at bestpractical.com
Tue Oct 28 12:47:48 EDT 2008


Author: sartak
Date: Tue Oct 28 12:47:43 2008
New Revision: 16565

Modified:
   Prophet/branches/class-dispatch/   (props changed)
   Prophet/branches/class-dispatch/lib/Prophet/CLI/Dispatcher.pm

Log:
 r74666 at onn:  sartak | 2008-10-28 12:47:08 -0400
 Support for trying app and Prophet classes


Modified: Prophet/branches/class-dispatch/lib/Prophet/CLI/Dispatcher.pm
==============================================================================
--- Prophet/branches/class-dispatch/lib/Prophet/CLI/Dispatcher.pm	(original)
+++ Prophet/branches/class-dispatch/lib/Prophet/CLI/Dispatcher.pm	Tue Oct 28 12:47:43 2008
@@ -53,8 +53,6 @@
 
     return sub {
         my $self = shift;
-        my $class = $self->class_name($name);
-        Prophet::App->require($class);
 
         my %constructor_args = (
             cli      => $self->cli,
@@ -64,16 +62,22 @@
             uuid     => $self->context->uuid,
         );
 
-    # undef causes type constraint violations
-    for my $key (keys %constructor_args) {
-        delete $constructor_args{$key}
-            if !defined($constructor_args{$key});
-    }
-        $class->new(%constructor_args)->run;
+        # undef causes type constraint violations
+        for my $key (keys %constructor_args) {
+            delete $constructor_args{$key}
+                if !defined($constructor_args{$key});
+        }
+
+        my @classes = $self->class_names($name);
+        for my $class (@classes) {
+            Prophet::App->try_to_require($class) or next;
+            $class->new(%constructor_args)->run;
+            last;
+        }
     };
 }
 
-sub class_name {
+sub class_names {
     my $self = shift;
     my $command = shift;
     return "Prophet::CLI::Command::$command";



More information about the Bps-public-commit mailing list