[Bps-public-commit] Path-Dispatcher branch, lazy-dispatch, updated. 0db862d98af5e08b4521c774b329cc48f0bdee75

sartak at bestpractical.com sartak at bestpractical.com
Fri Nov 6 20:58:21 EST 2009


The branch, lazy-dispatch has been updated
       via  0db862d98af5e08b4521c774b329cc48f0bdee75 (commit)
       via  260d26d7940e40e051b436deca3bd2fba87f9dfe (commit)
       via  f8e272766471d55d4e7a6a1d7beb2d6a95891ffe (commit)
       via  fad497861ef77666dc49b5fbeae30d4de76dfeb6 (commit)
      from  ee2983d69f351524c8c86756b59fb952104a1e5b (commit)

Summary of changes:
 lib/Path/Dispatcher.pm              |    4 +++-
 lib/Path/Dispatcher/Dispatch.pm     |    5 +++++
 lib/Path/Dispatcher/Match.pm        |    6 +-----
 lib/Path/Dispatcher/Role/HasPath.pm |   33 +++++++++++++++++++++++++++++++++
 4 files changed, 42 insertions(+), 6 deletions(-)
 create mode 100644 lib/Path/Dispatcher/Role/HasPath.pm

- Log -----------------------------------------------------------------
commit fad497861ef77666dc49b5fbeae30d4de76dfeb6
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Nov 6 20:55:20 2009 -0500

    Dispatch now has rules

diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index 62fa29b..3cb9c18 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -3,6 +3,8 @@ use Any::Moose;
 
 use Path::Dispatcher::Match;
 
+with 'Path::Dispatcher::Role::Rules';
+
 has _matches => (
     is        => 'rw',
     isa       => 'ArrayRef',

commit f8e272766471d55d4e7a6a1d7beb2d6a95891ffe
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Nov 6 20:56:56 2009 -0500

    Add a role for classes that have a path

diff --git a/lib/Path/Dispatcher/Role/HasPath.pm b/lib/Path/Dispatcher/Role/HasPath.pm
new file mode 100644
index 0000000..456e09d
--- /dev/null
+++ b/lib/Path/Dispatcher/Role/HasPath.pm
@@ -0,0 +1,33 @@
+package Path::Dispatcher::Role::HasPath;
+use Any::Moose '::Role';
+
+has path => (
+    is       => 'rw',
+    isa      => 'Path::Dispatcher::Path',
+    required => 1,
+);
+
+no Any::Moose;
+
+1;
+
+__END__
+
+=head1 NAME
+
+Path::Dispatcher::Role::HasPath - has a Path object
+
+=head1 DESCRIPTION
+
+Classes that consume this role get the following things:
+
+=head1 ATTRIBUTES
+
+=head2 path
+
+=head1 METHODS
+
+=head2 path
+
+=cut
+

commit 260d26d7940e40e051b436deca3bd2fba87f9dfe
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Nov 6 20:57:20 2009 -0500

    a Match has a Path

diff --git a/lib/Path/Dispatcher/Match.pm b/lib/Path/Dispatcher/Match.pm
index 5ba67b9..ac66457 100644
--- a/lib/Path/Dispatcher/Match.pm
+++ b/lib/Path/Dispatcher/Match.pm
@@ -4,11 +4,7 @@ use Any::Moose;
 use Path::Dispatcher::Path;
 use Path::Dispatcher::Rule;
 
-has path => (
-    is       => 'rw',
-    isa      => 'Path::Dispatcher::Path',
-    required => 1,
-);
+with 'Path::Dispatcher::Role::HasPath';
 
 has leftover => (
     is  => 'rw',

commit 0db862d98af5e08b4521c774b329cc48f0bdee75
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Fri Nov 6 20:58:15 2009 -0500

    Dispatch objects have a Path

diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index 7de099b..4f06d41 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -36,7 +36,9 @@ sub dispatch {
         );
     }
 
-    my $dispatch = $self->dispatch_class->new;
+    my $dispatch = $self->dispatch_class->new(
+        path => $path,
+    );
 
     for my $rule ($self->rules) {
         $self->dispatch_rule(
diff --git a/lib/Path/Dispatcher/Dispatch.pm b/lib/Path/Dispatcher/Dispatch.pm
index 3cb9c18..b3330c4 100644
--- a/lib/Path/Dispatcher/Dispatch.pm
+++ b/lib/Path/Dispatcher/Dispatch.pm
@@ -3,7 +3,10 @@ use Any::Moose;
 
 use Path::Dispatcher::Match;
 
-with 'Path::Dispatcher::Role::Rules';
+with (
+    'Path::Dispatcher::Role::Rules',
+    'Path::Dispatcher::Role::HasPath',
+);
 
 has _matches => (
     is        => 'rw',

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list