[Bps-public-commit] r17452 - in Path-Dispatcher/trunk: lib/Path/Dispatcher
sartak at bestpractical.com
sartak at bestpractical.com
Tue Dec 30 15:37:06 EST 2008
Author: sartak
Date: Tue Dec 30 15:37:06 2008
New Revision: 17452
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher/Declarative.pm
Log:
r78108 at onn: sartak | 2008-12-30 15:37:02 -0500
Refactor to avoid code duplication
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 Tue Dec 30 15:37:06 2008
@@ -136,17 +136,6 @@
$block ? (block => $block) : (),
),
},
- '' => sub {
- my ($self, $string, $block) = @_;
- my $case_sensitive = $self->case_sensitive_tokens;
-
- Path::Dispatcher::Rule::Tokens->new(
- tokens => [$string],
- delimiter => $self->token_delimiter,
- defined $case_sensitive ? (case_sensitive => $case_sensitive) : (),
- $block ? (block => $block) : (),
- ),
- },
CODE => sub {
my ($self, $matcher, $block) = @_;
Path::Dispatcher::Rule::CodeRef->new(
@@ -173,8 +162,17 @@
my ($self, $stage, $matcher, $block) = @_;
my $rule_creator;
- $rule_creator = $rule_creators{empty} if $matcher eq '';
- $rule_creator ||= $rule_creators{ ref $matcher };
+
+ if ($matcher eq '') {
+ $rule_creator = $rule_creators{empty};
+ }
+ elsif (!ref($matcher)) {
+ $rule_creator = $rule_creators{ARRAY};
+ $matcher = [$matcher];
+ }
+ else {
+ $rule_creator = $rule_creators{ ref $matcher };
+ }
$rule_creator or die "I don't know how to create a rule for type $matcher";
More information about the Bps-public-commit
mailing list