[Bps-public-commit] Path-Dispatcher branch, master, updated. a9dd88655f4aa8e7582e184b0cceca391ffe386e

sartak at bestpractical.com sartak at bestpractical.com
Tue Jan 19 22:09:00 EST 2010


The branch, master has been updated
       via  a9dd88655f4aa8e7582e184b0cceca391ffe386e (commit)
      from  6134cc3952297c877375ea5cb7084c744050b6e8 (commit)

Summary of changes:
 lib/Path/Dispatcher.pm |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

- Log -----------------------------------------------------------------
commit a9dd88655f4aa8e7582e184b0cceca391ffe386e
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Jan 19 22:08:42 2010 -0500

    Factor out path autoboxing

diff --git a/lib/Path/Dispatcher.pm b/lib/Path/Dispatcher.pm
index 8820ed1..7072fce 100644
--- a/lib/Path/Dispatcher.pm
+++ b/lib/Path/Dispatcher.pm
@@ -27,14 +27,7 @@ has name => (
 
 sub dispatch {
     my $self = shift;
-    my $path = shift;
-
-    # Automatically box paths
-    unless (blessed($path) && $path->isa('Path::Dispatcher::Path')) {
-        $path = $self->path_class->new(
-            path => $path,
-        );
-    }
+    my $path = $self->_autobox_path(shift);
 
     my $dispatch = $self->dispatch_class->new;
 
@@ -71,17 +64,23 @@ sub run {
 
 sub complete {
     my $self = shift;
+    my $path = $self->_autobox_path(shift);
+
+    my %seen;
+    return grep { !$seen{$_}++ } map { $_->complete($path) } $self->rules;
+}
+
+sub _autobox_path {
+    my $self = shift;
     my $path = shift;
 
-    # Automatically box paths
     unless (blessed($path) && $path->isa('Path::Dispatcher::Path')) {
         $path = $self->path_class->new(
             path => $path,
         );
     }
 
-    my %seen;
-    return grep { !$seen{$_}++ } map { $_->complete($path) } $self->rules;
+    return $path;
 }
 
 # We don't export anything, so if they request something, then try to error

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



More information about the Bps-public-commit mailing list