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

sartak at bestpractical.com sartak at bestpractical.com
Mon Aug 25 16:12:21 EDT 2008


Author: sartak
Date: Mon Aug 25 16:12:19 2008
New Revision: 15433

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

Log:
 r70289 at onn:  sartak | 2008-08-25 14:23:03 -0400
 Allow rules to have a stage object or name


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	Mon Aug 25 16:12:19 2008
@@ -74,7 +74,7 @@
 
     my $dispatch = $self->dispatch_class->new;
 
-    push @{ $rules_for_stage{$_->stage} }, $_
+    push @{ $rules_for_stage{$_->stage_name} }, $_
         for $self->rules;
 
     for my $stage ($self->stages) {

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	Mon Aug 25 16:12:19 2008
@@ -2,9 +2,11 @@
 package Path::Dispatcher::Rule;
 use Moose;
 
+use Path::Dispatcher::Stage;
+
 has stage => (
     is       => 'ro',
-    isa      => 'Str',
+    isa      => 'Str|Path::Dispatcher::Stage',
     default  => 'on',
     required => 1,
 );
@@ -25,6 +27,12 @@
     },
 );
 
+sub stage_name {
+    my $stage = shift->stage;
+    return $stage if !ref($stage);
+    return $stage->qualified_name;
+}
+
 sub match {
     my $self = shift;
     my $path = shift;



More information about the Bps-public-commit mailing list