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

sartak at bestpractical.com sartak at bestpractical.com
Sun Oct 19 07:40:25 EDT 2008


Author: sartak
Date: Sun Oct 19 07:40:14 2008
New Revision: 16373

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

Log:
 r74151 at onn:  sartak | 2008-10-19 07:39:32 -0400
 Allow passing in an already-instantiated rule to _add_rule


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm	Sun Oct 19 07:40:14 2008
@@ -134,15 +134,27 @@
 }
 
 sub _add_rule {
-    my ($dispatcher, $stage, $matcher, $block, @rest) = @_;
+    my $dispatcher = shift;
+    my $rule;
 
-    my $rule = _create_rule($stage, $matcher, $block);
+    if (!ref($_[0])) {
+        my ($stage, $matcher, $block) = splice @_, 0, 3;
+        $rule = _create_rule($stage, $matcher, $block);
+    }
+    else {
+        $rule = shift;
+    }
 
     if (!defined(wantarray)) {
-        $dispatcher->add_rule($rule);
+        if ($UNDER_RULE) {
+            $UNDER_RULE->add_rule($rule);
+        }
+        else {
+            $dispatcher->add_rule($rule);
+        }
     }
     else {
-        return $rule, @rest;
+        return $rule, @_;
     }
 }
 



More information about the Bps-public-commit mailing list