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

sartak at bestpractical.com sartak at bestpractical.com
Tue Feb 3 13:19:02 EST 2009


Author: sartak
Date: Tue Feb  3 13:19:02 2009
New Revision: 18152

Modified:
   Path-Dispatcher/trunk/   (props changed)
   Path-Dispatcher/trunk/Changes
   Path-Dispatcher/trunk/Makefile.PL
   Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Path.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/Rules.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Intersection.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Metadata.pm
   Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Under.pm

Log:
 r79598 at onn:  sartak | 2009-02-03 13:18:27 -0500
 Inline uses of MooseX::AttributeHelpers


Modified: Path-Dispatcher/trunk/Changes
==============================================================================
--- Path-Dispatcher/trunk/Changes	(original)
+++ Path-Dispatcher/trunk/Changes	Tue Feb  3 13:19:02 2009
@@ -1,6 +1,7 @@
 Revision history for Path-Dispatcher
 
 0.08
+        Inline uses of MooseX::AttributeHelpers.
 
 0.07 Wed Jan 28 01:39:37 2009
         Paths are now boxed with the new Path::Dispatcher::Path.

Modified: Path-Dispatcher/trunk/Makefile.PL
==============================================================================
--- Path-Dispatcher/trunk/Makefile.PL	(original)
+++ Path-Dispatcher/trunk/Makefile.PL	Tue Feb  3 13:19:02 2009
@@ -4,7 +4,6 @@
 all_from       'lib/Path/Dispatcher.pm';
 
 requires 'Moose';
-requires 'MooseX::AttributeHelpers';
 requires 'Sub::Exporter';
 
 build_requires 'Test::More';

Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher.pm	Tue Feb  3 13:19:02 2009
@@ -1,6 +1,5 @@
 package Path::Dispatcher;
 use Moose;
-use MooseX::AttributeHelpers;
 
 our $VERSION = '0.08';
 

Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Dispatch.pm	Tue Feb  3 13:19:02 2009
@@ -1,22 +1,28 @@
 package Path::Dispatcher::Dispatch;
 use Moose;
-use MooseX::AttributeHelpers;
 
 use Path::Dispatcher::Match;
 
 has _matches => (
-    metaclass => 'Collection::Array',
     is        => 'rw',
     isa       => 'ArrayRef[Path::Dispatcher::Match]',
     default   => sub { [] },
-    provides  => {
-        push     => 'add_match',
-        elements => 'matches',
-        count    => 'has_match',
-        first    => 'first_match',
-    },
 );
 
+sub add_match {
+    my $self = shift;
+
+    $_->isa('Path::Dispatcher::Match')
+        or confess "$_ is not a Path::Dispatcher::Match"
+            for @_;
+
+    push @{ $self->{matches} }, @_;
+}
+
+sub matches     { @{ shift->{matches} } }
+sub has_match   { scalar @{ shift->{matches} } }
+sub first_match { shift->{matches}[0] }
+
 # aliases
 __PACKAGE__->meta->add_method(add_matches => __PACKAGE__->can('add_match'));
 __PACKAGE__->meta->add_method(has_matches => __PACKAGE__->can('has_match'));

Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Path.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Path.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Path.pm	Tue Feb  3 13:19:02 2009
@@ -1,6 +1,5 @@
 package Path::Dispatcher::Path;
 use Moose;
-use MooseX::AttributeHelpers;
 
 use overload q{""} => sub { shift->path };
 
@@ -11,13 +10,9 @@
 );
 
 has metadata => (
-    metaclass => 'Collection::Hash',
     is        => 'rw',
     isa       => 'HashRef',
     predicate => 'has_metadata',
-    provides  => {
-        get => 'get_metadata',
-    },
 );
 
 # allow Path::Dispatcher::Path->new($path)
@@ -39,6 +34,13 @@
     return $self->meta->clone_instance($self, path => $path, @_);
 }
 
+sub get_metadata {
+    my $self = shift;
+    my $name = shift;
+
+    return $self->metadata->{$name};
+}
+
 __PACKAGE__->meta->make_immutable;
 no Moose;
 

Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/Rules.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/Rules.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Role/Rules.pm	Tue Feb  3 13:19:02 2009
@@ -2,16 +2,23 @@
 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',
-    },
+    is       => 'rw',
+    isa      => 'ArrayRef[Path::Dispatcher::Rule]',
+    init_arg => 'rules',
+    default  => sub { [] },
 );
 
+sub add_rule {
+    my $self = shift;
+
+    $_->isa('Path::Dispatcher::Rule')
+        or confess "$_ is not a Path::Dispatcher::Rule"
+            for @_;
+
+    push @{ $self->{_rules} }, @_;
+}
+
+sub rules { @{ shift->{_rules} } }
+
 1;
 

Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Intersection.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Intersection.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Intersection.pm	Tue Feb  3 13:19:02 2009
@@ -1,6 +1,5 @@
 package Path::Dispatcher::Rule::Intersection;
 use Moose;
-use MooseX::AttributeHelpers;
 extends 'Path::Dispatcher::Rule';
 
 with 'Path::Dispatcher::Role::Rules';

Modified: Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Metadata.pm
==============================================================================
--- Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Metadata.pm	(original)
+++ Path-Dispatcher/trunk/lib/Path/Dispatcher/Rule/Metadata.pm	Tue Feb  3 13:19:02 2009
@@ -1,6 +1,5 @@
 package Path::Dispatcher::Rule::Metadata;
 use Moose;
-use MooseX::AttributeHelpers;
 extends 'Path::Dispatcher::Rule';
 
 has field => (

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 Feb  3 13:19:02 2009
@@ -1,7 +1,6 @@
 package Path::Dispatcher::Rule::Under;
 use Moose;
 use Moose::Util::TypeConstraints;
-use MooseX::AttributeHelpers;
 
 extends 'Path::Dispatcher::Rule';
 with 'Path::Dispatcher::Role::Rules';



More information about the Bps-public-commit mailing list