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

sartak at bestpractical.com sartak at bestpractical.com
Sun Oct 19 07:14:21 EDT 2008


Author: sartak
Date: Sun Oct 19 07:13:43 2008
New Revision: 16370

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

Log:
 r74143 at onn:  sartak | 2008-10-19 07:12:14 -0400
 Split the create/add phases of declarative rule creation


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:13:43 2008
@@ -114,14 +114,25 @@
     },
 );
 
-sub _add_rule {
-    my ($dispatcher, $stage, $matcher, $block) = @_;
+sub _create_rule {
+    my ($stage, $matcher, $block) = @_;
 
     my $rule_creator = $rule_creator{ ref $matcher }
         or die "I don't know how to create a rule for type $matcher";
-    my $rule = $rule_creator->($matcher, $block);
+    return $rule_creator->($matcher, $block);
+}
+
+sub _add_rule {
+    my ($dispatcher, $stage, $matcher, $block, @rest) = @_;
+
+    my $rule = _create_rule($stage, $matcher, $block);
 
-    $dispatcher->add_rule($rule);
+    if (!defined(wantarray)) {
+        $dispatcher->add_rule($rule);
+    }
+    else {
+        return $rule, @rest;
+    }
 }
 
 1;



More information about the Bps-public-commit mailing list