[Bps-public-commit] r15449 - in Path-Dispatcher/trunk: lib/Path lib/Path/Dispatcher lib/Path/Dispatcher/Dispatch
sartak at bestpractical.com
sartak at bestpractical.com
Mon Aug 25 19:21:14 EDT 2008
Author: sartak
Date: Mon Aug 25 19:21:13 2008
New Revision: 15449
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm
Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch/Match.pm
Path-Dispatcher/trunk/lib/Path/Dispatcher/Stage.pm
Log:
r70328 at onn: sartak | 2008-08-25 19:21:07 -0400
We need to "stop" during run, not dispatch, because if something calls next_rule, it's akin to $self->SUPER::method
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 19:21:13 2008
@@ -64,23 +64,11 @@
my $dispatch = $self->dispatch_class->new;
for my $stage ($self->stages) {
- my $stop = $self->dispatch_stage(
+ $self->dispatch_stage(
stage => $stage,
dispatch => $dispatch,
path => $path,
);
-
- if ($stop) {
- if ($stage->has_cleanup_stage) {
- $self->dispatch_stage(
- stage => $stage->cleanup_stage,
- dispatch => $dispatch,
- path => $path,
- );
- }
-
- return $dispatch;
- }
}
$dispatch->add_redispatches($self->redispatches($path))
@@ -96,14 +84,11 @@
my $stage = $args{stage};
for my $rule ($stage->rules) {
- my $matched = $self->dispatch_rule(
+ $self->dispatch_rule(
%args,
rule => $rule,
);
- return 1 if $matched && $stage->match_ends_dispatch;
}
-
- return 0;
}
sub dispatch_rule {
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm Mon Aug 25 19:21:13 2008
@@ -55,6 +55,7 @@
local $SIG{__DIE__} = 'DEFAULT';
for my $match ($self->matches) {
$match->run(@args);
+ last if $match->ends_dispatch($self);
}
};
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch/Match.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch/Match.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch/Match.pm Mon Aug 25 19:21:13 2008
@@ -58,6 +58,14 @@
$code->();
}
+# If we're a before/after (qualified) rule, then yeah, we want to continue
+# dispatching. If we're an "on" (unqualified) rule, then no, you only get one.
+sub ends_dispatch {
+ my $self = shift;
+
+ return $self->stage->is_qualified ? 0 : 1;
+}
+
__PACKAGE__->meta->make_immutable;
no Moose;
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Stage.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Stage.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Stage.pm Mon Aug 25 19:21:13 2008
@@ -41,12 +41,6 @@
return $name;
}
-# If we're a before/after (qualified) rule, then yeah, we want to continue
-# dispatching. If we're an "on" (unqualified) rule, then no, you only get one.
-sub match_ends_dispatch {
- return !shift->is_qualified;
-}
-
no Moose;
__PACKAGE__->meta->make_immutable;
More information about the Bps-public-commit
mailing list