[Bps-public-commit] Path-Dispatcher branch, master, updated. 3251b72b1d61dd78998e162e18225b7cb5cb0dd7
sartak at bestpractical.com
sartak at bestpractical.com
Fri Mar 6 21:24:02 EST 2009
The branch, master has been updated
via 3251b72b1d61dd78998e162e18225b7cb5cb0dd7 (commit)
from 8b8043934d379e31469dc98cd9d51b3302bed497 (commit)
Summary of changes:
lib/Path/Dispatcher/Builder.pm | 18 +++---------------
lib/Path/Dispatcher/Declarative.pm | 2 --
lib/Path/Dispatcher/Dispatch.pm | 5 ++---
lib/Path/Dispatcher/Match.pm | 8 --------
t/004-run.t | 6 +-----
t/102-abort.t | 8 +-------
6 files changed, 7 insertions(+), 40 deletions(-)
- Log -----------------------------------------------------------------
commit 3251b72b1d61dd78998e162e18225b7cb5cb0dd7
Author: Shawn M Moore <sartak at gmail.com>
Date: Fri Mar 6 21:23:50 2009 -0500
Begin removing ends_dispatch and before/after
diff --git a/lib/Path/Dispatcher/Builder.pm b/lib/Path/Dispatcher/Builder.pm
index ba9d7a1..aba953b 100644
--- a/lib/Path/Dispatcher/Builder.pm
+++ b/lib/Path/Dispatcher/Builder.pm
@@ -1,6 +1,9 @@
package Path::Dispatcher::Builder;
use Any::Moose;
+our $OUTERMOST_DISPATCHER;
+our $UNDER_RULE;
+
has dispatcher => (
is => 'ro',
isa => 'Path::Dispatcher',
@@ -20,11 +23,6 @@ has token_delimiter => (
default => ' ',
);
-no Any::Moose; # We're gonna use before/after below
-
-our $OUTERMOST_DISPATCHER;
-our $UNDER_RULE;
-
sub _next_rule () {
die "Path::Dispatcher next rule\n";
}
@@ -68,16 +66,6 @@ sub on {
$self->_add_rule('on', @_);
}
-sub before {
- my $self = shift;
- $self->_add_rule('before_on', @_);
-}
-
-sub after {
- my $self = shift;
- $self->_add_rule('after_on', @_);
-}
-
sub then {
my $self = shift;
my $block = shift;
diff --git a/lib/Path/Dispatcher/Declarative.pm b/lib/Path/Dispatcher/Declarative.pm
index 0f73bea..ae85dcf 100644
--- a/lib/Path/Dispatcher/Declarative.pm
+++ b/lib/Path/Dispatcher/Declarative.pm
@@ -80,8 +80,6 @@ sub build_sugar {
rewrite => sub { $lazy_builder->()->rewrite(@_) },
on => sub { $lazy_builder->()->on(@_) },
- before => sub { $lazy_builder->()->before(@_) },
- after => sub { $lazy_builder->()->after(@_) },
then => sub (&) { $lazy_builder->()->then(@_) },
chain => sub (&) { $lazy_builder->()->chain(@_) },
under => sub { $lazy_builder->()->under(@_) },
diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index b425bc0..7e8b6c2 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -42,8 +42,7 @@ sub run {
push @results, scalar $match->run(@args);
- die "Path::Dispatcher abort\n"
- if $match->ends_dispatch;
+ die "Path::Dispatcher abort\n";
};
if ($@) {
@@ -103,7 +102,7 @@ matched.
=head2 run
-Executes matches until a match's C<ends_dispatch> returns true.
+Executes the first match.
Each match's L<Path::Dispatcher::Match/run> method is evaluated in scalar
context. The return value of this method is a list of these scalars (or the
diff --git a/lib/Path/Dispatcher/Match.pm b/lib/Path/Dispatcher/Match.pm
index 5a67b09..f286f80 100644
--- a/lib/Path/Dispatcher/Match.pm
+++ b/lib/Path/Dispatcher/Match.pm
@@ -32,14 +32,6 @@ has set_number_vars => (
default => sub { ref(shift->result) eq 'ARRAY' },
);
-# 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.
-has ends_dispatch => (
- is => 'rw',
- isa => 'Bool',
- default => 1,
-);
-
sub run {
my $self = shift;
my @args = @_;
diff --git a/t/004-run.t b/t/004-run.t
index 02558a5..bf01282 100644
--- a/t/004-run.t
+++ b/t/004-run.t
@@ -27,13 +27,9 @@ $result = $dispatcher->run("foobar");
is($result, "foobar matched");
my $dispatch = $dispatcher->dispatch("foobar");
-for my $match ($dispatch->matches) {
- $match->ends_dispatch(0);
-}
-
$result = $dispatch->run("foobar");
is($result, "foobar matched");
my @results = $dispatch->run("foobar");
-is_deeply(\@results, ["foobar matched", "foo matched"]);
+is_deeply(\@results, ["foobar matched"]);
diff --git a/t/102-abort.t b/t/102-abort.t
index 2c2ae15..6674973 100644
--- a/t/102-abort.t
+++ b/t/102-abort.t
@@ -28,12 +28,6 @@ do {
# this hack is here because "use" expects there to be a file for the module
BEGIN { MyFramework::Dispatcher->import("-base") }
- before qr/abort/ => sub {
- push @calls, 'app before abort';
- last_rule;
- push @calls, 'app after abort';
- };
-
on qr/next rule/ => sub {
push @calls, 'app before next_rule';
next_rule;
@@ -51,7 +45,7 @@ do {
MyApp::Dispatcher->run('abort');
is_deeply([splice @calls], [
- 'app before abort',
+ 'framework on abort',
]);
MyApp::Dispatcher->run('next rule');
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list