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

sartak at bestpractical.com sartak at bestpractical.com
Wed Feb 4 16:07:05 EST 2009


Author: sartak
Date: Wed Feb  4 16:07:02 2009
New Revision: 18209

Removed:
   Path-Dispatcher/trunk/t/903-weird-token.t
Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Dispatch.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Tokens.pm

Log:
 r79699 at onn:  sartak | 2009-02-04 16:06:38 -0500
 Depend on Moose::Util::TypeConstraints less


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Dispatch.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Dispatch.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Dispatch.pm	Wed Feb  4 16:07:02 2009
@@ -20,7 +20,6 @@
 
 __PACKAGE__->meta->make_immutable;
 no Moose;
-no Moose::Util::TypeConstraints;
 
 1;
 

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 Feb  4 16:07:02 2009
@@ -1,36 +1,10 @@
 package Path::Dispatcher::Rule::Tokens;
 use Moose;
-use Moose::Util::TypeConstraints;
 extends 'Path::Dispatcher::Rule';
 
-# a token may be
-#   - a string
-#   - a regular expression
-
-# this will be extended to add
-#   - an array reference containing (alternations)
-#     - strings
-#     - regular expressions
-
-my $Str      = find_type_constraint('Str');
-my $Regex    = find_type_constraint('RegexpRef');
-my $ArrayRef = find_type_constraint('ArrayRef');
-
-my $Alternation;
-$Alternation = subtype as 'Defined'
-     => where {
-         return $Str->check($_) || $Regex->check($_) if ref($_) ne 'ARRAY';
-         $Alternation->check($_) or return for @$_;
-         1
-     };
-
-subtype 'Path::Dispatcher::Tokens'
-     => as 'ArrayRef'
-     => where { $Alternation->check($_) or return for @$_; 1 };
-
 has tokens => (
     is         => 'rw',
-    isa        => 'Path::Dispatcher::Tokens',
+    isa        => 'ArrayRef',
     auto_deref => 1,
     required   => 1,
 );
@@ -91,16 +65,16 @@
     my $got      = shift;
     my $expected = shift;
 
-    if ($ArrayRef->check($expected)) {
+    if (!ref($expected)) {
+        ($got, $expected) = (lc $got, lc $expected) if !$self->case_sensitive;
+        return $got eq $expected;
+    }
+    elsif (ref($expected) eq 'ARRAY') {
         for my $alternative (@$expected) {
             return 1 if $self->_match_token($got, $alternative);
         }
     }
-    elsif ($Str->check($expected)) {
-        ($got, $expected) = (lc $got, lc $expected) if !$self->case_sensitive;
-        return $got eq $expected;
-    }
-    elsif ($Regex->check($expected)) {
+    elsif (ref($expected) eq 'Regexp') {
         return $got =~ $expected;
     }
     else {
@@ -166,7 +140,6 @@
 
 __PACKAGE__->meta->make_immutable;
 no Moose;
-no Moose::Util::TypeConstraints;
 
 1;
 



More information about the Bps-public-commit mailing list