[Bps-public-commit] r16912 - in Path-Dispatcher/trunk: lib/Path lib/Path/Dispatcher/Role lib/Path/Dispatcher/Rule
sartak at bestpractical.com
sartak at bestpractical.com
Tue Nov 18 19:31:28 EST 2008
Author: sartak
Date: Tue Nov 18 19:31:28 2008
New Revision: 16912
Added:
Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/
Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/Rules.pm
Modified:
Path-Dispatcher/trunk/ (props changed)
Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Under.pm
Log:
r75775 at onn: sartak | 2008-11-18 19:31:25 -0500
Factor out the "collection of rules" attribute into a role
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher.pm Tue Nov 18 19:31:28 2008
@@ -12,6 +12,8 @@
use constant dispatch_class => 'Path::Dispatcher::Dispatch';
use constant path_class => 'Path::Dispatcher::Path';
+with 'Path::Dispatcher::Role::Rules';
+
has name => (
is => 'rw',
isa => 'Str',
@@ -24,18 +26,6 @@
},
);
-has _rules => (
- metaclass => 'Collection::Array',
- is => 'rw',
- isa => 'ArrayRef[Path::Dispatcher::Rule]',
- init_arg => 'rules',
- default => sub { [] },
- provides => {
- push => 'add_rule',
- elements => 'rules',
- },
-);
-
sub dispatch {
my $self = shift;
my $path = shift;
Added: Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/Rules.pm
==============================================================================
--- (empty file)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/Rules.pm Tue Nov 18 19:31:28 2008
@@ -0,0 +1,18 @@
+#!/usr/bin/env perl
+package Path::Dispatcher::Role::Rules;
+use Moose::Role;
+
+has _rules => (
+ metaclass => 'Collection::Array',
+ is => 'rw',
+ isa => 'ArrayRef[Path::Dispatcher::Rule]',
+ init_arg => 'rules',
+ default => sub { [] },
+ provides => {
+ push => 'add_rule',
+ elements => 'rules',
+ },
+);
+
+1;
+
Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Under.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Under.pm (original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Under.pm Tue Nov 18 19:31:28 2008
@@ -3,7 +3,9 @@
use Moose;
use Moose::Util::TypeConstraints;
use MooseX::AttributeHelpers;
+
extends 'Path::Dispatcher::Rule';
+with 'Path::Dispatcher::Role::Rules';
subtype 'Path::Dispatcher::PrefixRule'
=> as 'Path::Dispatcher::Rule'
@@ -15,18 +17,6 @@
isa => 'Path::Dispatcher::PrefixRule',
);
-has _rules => (
- metaclass => 'Collection::Array',
- is => 'rw',
- isa => 'ArrayRef[Path::Dispatcher::Rule]',
- init_arg => 'rules',
- default => sub { [] },
- provides => {
- push => 'add_rule',
- elements => 'rules',
- },
-);
-
sub match {
my $self = shift;
my $path = shift;
More information about the Bps-public-commit
mailing list