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

sartak at bestpractical.com sartak at bestpractical.com
Tue Oct 21 07:34:14 EDT 2008


Author: sartak
Date: Tue Oct 21 07:34:14 2008
New Revision: 16410

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

Log:
 r74234 at onn:  sartak | 2008-10-21 07:34:10 -0400
 Factor out (un)tokenization into methods


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm	Tue Oct 21 07:34:14 2008
@@ -45,7 +45,7 @@
     my $self = shift;
     my $path = shift;
 
-    my @tokens = grep { length } split $self->delimiter, $path;
+    my @tokens = $self->tokenize($path);
     my @matched;
 
     for my $expected ($self->tokens) {
@@ -55,7 +55,7 @@
         push @matched, $got;
     }
 
-    my $leftover = join $self->delimiter, @tokens;
+    my $leftover = $self->untokenize(@tokens);
     return \@matched, $leftover;
 }
 
@@ -79,6 +79,18 @@
     return 0;
 }
 
+sub tokenize {
+    my $self = shift;
+    my $path = shift;
+    return grep { length } split $self->delimiter, $path;
+}
+
+sub untokenize {
+    my $self   = shift;
+    my @tokens = @_;
+    return join $self->delimiter, @tokens;
+}
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 no Moose::Util::TypeConstraints;



More information about the Bps-public-commit mailing list