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

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 13 05:36:57 EDT 2008


Author: sartak
Date: Wed Aug 13 05:36:55 2008
New Revision: 15111

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

Log:
 r69458 at onn:  sartak | 2008-08-13 05:36:48 -0400
 Simplest implementation of tokens rule


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	Wed Aug 13 05:36:55 2008
@@ -4,14 +4,32 @@
 extends 'Path::Dispatcher::Rule';
 
 has tokens => (
-    is       => 'ro',
-    isa      => 'ArrayRef[ArrayRef[Str|RegexpRef]]',
-    required => 1,
+    is         => 'ro',
+    isa        => 'ArrayRef[Str]',
+    auto_deref => 1,
+    required   => 1,
+);
+
+has splitter => (
+    is      => 'ro',
+    isa     => 'Str',
+    default => ' ',
 );
 
 sub _match {
     my $self = shift;
     my $path = shift;
+
+    my @tokens = split $self->splitter, $path;
+
+    for my $expected ($self->tokens) {
+        my $got = shift @tokens;
+
+        return if $got ne $expected;
+    }
+
+    return if @tokens;
+    return 1;
 }
 
 __PACKAGE__->meta->make_immutable;



More information about the Bps-public-commit mailing list