[Bps-public-commit] r14610 - in Path-Dispatcher/trunk: lib/Path/Dispatcher t
sartak at bestpractical.com
sartak at bestpractical.com
Tue Jul 29 14:42:27 EDT 2008
Author: sartak
Date: Tue Jul 29 14:42:27 2008
New Revision: 14610
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm
Path-Dispatcher/trunk/t/001-api.t
Log:
r67890 at onn: sartak | 2008-07-29 14:41:49 -0400
Tweak rule a little, add matches and run methods
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 Tue Jul 29 14:42:27 2008
@@ -15,7 +15,7 @@
required => 1,
);
-has run => (
+has block => (
is => 'rw',
isa => 'CodeRef',
required => 1,
@@ -32,6 +32,20 @@
return $args;
};
+sub matches {
+ my $self = shift;
+ my $path = shift;
+
+ return $path =~ $self->match;
+}
+
+sub run {
+ my $self = shift;
+ my $path = shift;
+
+ $self->block->($path);
+}
+
__PACKAGE__->meta->make_immutable;
no Moose;
Modified: Path-Dispatcher/trunk/t/001-api.t
==============================================================================
--- Path-Dispatcher/trunk/t/001-api.t (original)
+++ Path-Dispatcher/trunk/t/001-api.t Tue Jul 29 14:42:27 2008
@@ -10,7 +10,7 @@
$dispatcher->add_rule(
stage => 'on',
match => 'foo',
- run => sub { ++$calls },
+ block => sub { ++$calls },
);
is($calls, 0, "no calls to the dispatcher block yet");
More information about the Bps-public-commit
mailing list