[Bps-public-commit] r14813 - in Path-Dispatcher/trunk: lib/Path lib/Path/Dispatcher

sartak at bestpractical.com sartak at bestpractical.com
Tue Aug 5 18:42:52 EDT 2008


Author: sartak
Date: Tue Aug  5 18:42:51 2008
New Revision: 14813

Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm

Log:
 r54126 at gorgoroth:  sartak | 2008-08-05 18:42:43 -0400
 We can now pass arguments to each rule's block from "run" or invoking the coderef returned by "dispatch"


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	Tue Aug  5 18:42:51 2008
@@ -127,23 +127,25 @@
     my $matches = $args{matches};
 
     return sub {
+        my @args = @_;
+
         eval {
             local $SIG{__DIE__} = 'DEFAULT';
             for my $match (@$matches) {
                 if (ref($match) eq 'CODE') {
-                    $match->();
+                    $match->(@args);
                     next;
                 }
 
                 # if we need to set $1, $2..
                 if (ref($match->{result}) eq 'ARRAY') {
                     $self->run_with_number_vars(
-                        sub { $match->{rule}->run($path) },
+                        sub { $match->{rule}->run(@args) },
                         @{ $match->{result} },
                     );
                 }
                 else {
-                    $match->{rule}->run($path);
+                    $match->{rule}->run(@args);
                 }
             }
         };
@@ -169,9 +171,10 @@
 
 sub run {
     my $self = shift;
-    my $code = $self->dispatch(@_);
+    my $path = shift;
+    my $code = $self->dispatch($path);
 
-    return $code->();
+    return $code->(@_);
 }
 
 sub begin_stage {}

Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	Tue Aug  5 18:42:51 2008
@@ -82,9 +82,8 @@
 
 sub run {
     my $self = shift;
-    my $path = shift;
 
-    $self->block->();
+    $self->block->(@_);
 }
 
 __PACKAGE__->meta->make_immutable;



More information about the Bps-public-commit mailing list