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

sartak at bestpractical.com sartak at bestpractical.com
Sat Nov 15 20:59:01 EST 2008


Author: sartak
Date: Sat Nov 15 20:59:01 2008
New Revision: 16850

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

Log:
 r75555 at onn:  sartak | 2008-11-15 20:58:57 -0500
 Add an "empty" rule


Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm	Sat Nov 15 20:59:01 2008
@@ -63,6 +63,7 @@
 require Path::Dispatcher::Rule::Always;
 require Path::Dispatcher::Rule::CodeRef;
 require Path::Dispatcher::Rule::Dispatch;
+require Path::Dispatcher::Rule::Empty;
 require Path::Dispatcher::Rule::Regex;
 require Path::Dispatcher::Rule::Tokens;
 require Path::Dispatcher::Rule::Under;

Added: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Empty.pm
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Empty.pm	Sat Nov 15 20:59:01 2008
@@ -0,0 +1,29 @@
+#!/usr/bin/env perl
+package Path::Dispatcher::Rule::Always;
+use Moose;
+extends 'Path::Dispatcher::Rule';
+
+sub _match {
+    my $self = shift;
+    my $path = shift;
+    return 0 if length $path;
+    return (1, $path);
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+
+__END__
+
+=head1 NAME
+
+Path::Dispatcher::Rule::Empty - matches only the empty path
+
+=head1 DESCRIPTION
+
+Rules of this class match only the empty path.
+
+=cut
+



More information about the Bps-public-commit mailing list