[Bps-public-commit] r16913 - in Path-Dispatcher/trunk: lib/Path/Dispatcher lib/Path/Dispatcher/Rule
sartak at bestpractical.com
sartak at bestpractical.com
Tue Nov 18 19:34:05 EST 2008
Author: sartak
Date: Tue Nov 18 19:34:05 2008
New Revision: 16913
Added:
Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Intersection.pm
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule.pm
Log:
r75777 at onn: sartak | 2008-11-18 19:34:02 -0500
Implementation of an "intersection" rule; all its rules must match
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 Tue Nov 18 19:34:05 2008
@@ -64,6 +64,7 @@
require Path::Dispatcher::Rule::CodeRef;
require Path::Dispatcher::Rule::Dispatch;
require Path::Dispatcher::Rule::Empty;
+require Path::Dispatcher::Rule::Intersection;
require Path::Dispatcher::Rule::Regex;
require Path::Dispatcher::Rule::Tokens;
require Path::Dispatcher::Rule::Under;
Added: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Intersection.pm
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Intersection.pm Tue Nov 18 19:34:05 2008
@@ -0,0 +1,40 @@
+#!/usr/bin/env perl
+package Path::Dispatcher::Rule::Intersection;
+use Moose;
+use MooseX::AttributeHelpers;
+extends 'Path::Dispatcher::Rule';
+
+with 'Path::Dispatcher::Role::Rules';
+
+sub _match {
+ my $self = shift;
+ my $path = shift;
+
+ for my $rule ($self->rules) {
+ return 0 unless $rule->match($path);
+ }
+
+ return 1;
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+
+__END__
+
+=head1 NAME
+
+Path::Dispatcher::Rule::Intersection - all rules must match
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+=head1 ATTRIBUTES
+
+=head2 rules
+
+=cut
+
More information about the Bps-public-commit
mailing list