X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FDispatchType%2FPath.pm;h=5c1e4ed4f7d956c8dc7a89ad40c0f820f449f722;hp=56c1083632ffabc24e98b38088157f6aa62a3583;hb=91955398bb1d5dba2bca876b1e21d2ea9b93919b;hpb=536bee890cf24e0e4bcda7562e7b70cc03ca0620 diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 56c1083..5c1e4ed 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -6,7 +6,6 @@ extends 'Catalyst::DispatchType'; use Text::SimpleTable; use Catalyst::Utils; use URI; -use Scalar::Util (); has _paths => ( is => 'rw', @@ -49,7 +48,7 @@ Debug output for Path dispatch points sub list { my ( $self, $c ) = @_; my $column_width = Catalyst::Utils::term_width() - 35 - 9; - my $paths = Text::SimpleTable->new( + my $paths = Text::SimpleTable->new( [ 35, 'Path' ], [ $column_width, 'Private' ] ); foreach my $path ( sort keys %{ $self->_paths } ) { @@ -62,16 +61,6 @@ sub list { if ( keys %{ $self->_paths } ); } -sub _action_args_sort_order { - my ( $self, $action ) = @_; - - my ($args) = @{ $action->attributes->{Args} || [] }; - - return $args if Scalar::Util::looks_like_number($args); - - return ~0; -} - =head2 $self->match( $c, $path ) For each action registered to this exact path, offers the action a chance to @@ -85,10 +74,7 @@ sub match { $path = '/' if !defined $path || !length $path; - # sort from least args to most - my @actions = sort { $self->_action_args_sort_order($a) <=> - $self->_action_args_sort_order($b) } - @{ $self->_paths->{$path} || [] }; + my @actions = @{ $self->_paths->{$path} || [] }; foreach my $action ( @actions ) { next unless $action->match($c); @@ -131,7 +117,9 @@ sub register_path { $path = '/' unless length $path; $path = URI->new($path)->canonical; - unshift( @{ $self->_paths->{$path} ||= [] }, $action); + $self->_paths->{$path} = [ + sort { $a <=> $b } ($action, @{ $self->_paths->{$path} || [] }) + ]; return 1; }