From: Matt S Trout Date: Wed, 15 Dec 2010 12:14:20 +0000 (+0000) Subject: factor out match_not X-Git-Tag: v0.005~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FWeb-Simple.git;a=commitdiff_plain;h=ce573717455fc7127db16207de0342c65cc00ad5 factor out match_not --- diff --git a/lib/Web/Dispatch/Parser.pm b/lib/Web/Dispatch/Parser.pm index 69c510b..92aa9b6 100644 --- a/lib/Web/Dispatch/Parser.pm +++ b/lib/Web/Dispatch/Parser.pm @@ -106,13 +106,7 @@ sub _parse_spec_section { # !something /\G!/gc and - return do { - my $match = $self->_parse_spec_section($_); - return sub { - return {} unless my @discard = $match->(@_); - return; - }; - }; + return match_not($self->_parse_spec_section($_)); # ? /\G\?/gc and diff --git a/lib/Web/Dispatch/Predicates.pm b/lib/Web/Dispatch/Predicates.pm index bfc5f2f..f47605b 100644 --- a/lib/Web/Dispatch/Predicates.pm +++ b/lib/Web/Dispatch/Predicates.pm @@ -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 {