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

sartak at bestpractical.com sartak at bestpractical.com
Wed Jan 28 01:25:58 EST 2009


Author: sartak
Date: Wed Jan 28 01:25:56 2009
New Revision: 17948

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

Log:
 r79160 at onn:  sartak | 2009-01-28 01:25:14 -0500
 Metadata sugar


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	Wed Jan 28 01:25:56 2009
@@ -136,6 +136,23 @@
             $block ? (block => $block) : (),
         ),
     },
+    HASH => sub {
+        my ($self, $stage, $metadata_matchers, $block) = @_;
+
+        if (keys %$metadata_matchers == 1) {
+            my ($field) = keys %$metadata_matchers;
+            my ($value) = values %$metadata_matchers;
+            my $matcher = $self->_create_rule($stage, $value);
+
+            return Path::Dispatcher::Rule::Metadata->new(
+                field   => $field,
+                matcher => $matcher,
+                $block ? (block => $block) : (),
+            );
+        }
+
+        die "Doesn't support multiple metadata rules yet";
+    },
     CODE => sub {
         my ($self, $stage, $matcher, $block) = @_;
         Path::Dispatcher::Rule::CodeRef->new(



More information about the Bps-public-commit mailing list