factor out match_not
[catagits/Web-Simple.git] / lib / Web / Dispatch / Predicates.pm
index bfc5f2f..f47605b 100644 (file)
@@ -4,7 +4,7 @@ use strictures 1;
 use base qw(Exporter);
 
 our @EXPORT = qw(
-  match_and match_or match_method match_path match_path_strip
+  match_and match_or match_not match_method match_path match_path_strip
   match_extension
 );
 
@@ -41,6 +41,17 @@ sub match_or {
   }
 }
 
+sub match_not {
+  my ($match) = @_;
+  sub {
+    if (my @discard = $match->($_[0])) {
+      ();
+    } else {
+      ({});
+    }
+  }
+}
+
 sub match_method {
   my ($method) = @_;
   sub {