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

sartak at bestpractical.com sartak at bestpractical.com
Tue Nov 18 20:00:28 EST 2008


Author: sartak
Date: Tue Nov 18 20:00:28 2008
New Revision: 16918

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

Log:
 r75787 at onn:  sartak | 2008-11-18 20:00:25 -0500
 Make metadata only match a single metadata value


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Metadata.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Metadata.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Metadata.pm	Tue Nov 18 20:00:28 2008
@@ -4,40 +4,27 @@
 use MooseX::AttributeHelpers;
 extends 'Path::Dispatcher::Rule';
 
-has match_metadata => (
-    metaclass => 'Collection::Hash',
-    is        => 'rw',
-    isa       => 'HashRef',
-    required  => 1,
-    provides  => {
-        keys => 'metadata_keys',
-        get  => 'metadata',
-    },
+has name => (
+    is       => 'rw',
+    isa      => 'Str',
+    required => 1,
+);
+
+has value => (
+    is       => 'rw',
+    isa      => 'Str',
+    required => 1,
 );
 
 sub _match {
     my $self = shift;
     my $path = shift;
+    my $got = $path->get_metadata($self->name);
 
-    my $path_metadata = $path->metadata;
-
-    for my $key ($self->metadata_keys) {
-        return 0 if !exists($path_metadata->{$key});
-
-        $self->_match_metadatum($path_metadata->{$key}, $self->metadata($key))
-            or return 0;
-    }
+    return 0 if $self->value ne $got;
 
     return 1, $path->path;
 }
 
-sub _match_metadatum {
-    my $self     = shift;
-    my $got      = shift;
-    my $expected = shift;
-
-    return $got eq $expected;
-}
-
 1;
 



More information about the Bps-public-commit mailing list