From: Rafael Kitover Date: Sat, 20 Jun 2009 17:18:53 +0000 (+0000) Subject: minor changes X-Git-Tag: 5.80006~43 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=91955398bb1d5dba2bca876b1e21d2ea9b93919b minor changes --- diff --git a/lib/Catalyst/Action.pm b/lib/Catalyst/Action.pm index 0eb9942..97b9235 100644 --- a/lib/Catalyst/Action.pm +++ b/lib/Catalyst/Action.pm @@ -124,6 +124,14 @@ context and arguments Check Args attribute, and makes sure number of args matches the setting. Always returns true if Args is omitted. +=head2 sort_order + +Returns the value of the C attribute, or C<~0> if it has no value. + +=head2 compare + +Returns C<< $a->sort_order <=> $b->sort_order >> . + =head2 namespace Returns the private namespace this action lives in. diff --git a/lib/Catalyst/DispatchType/Path.pm b/lib/Catalyst/DispatchType/Path.pm index 50fbf84..5c1e4ed 100644 --- a/lib/Catalyst/DispatchType/Path.pm +++ b/lib/Catalyst/DispatchType/Path.pm @@ -74,7 +74,9 @@ sub match { $path = '/' if !defined $path || !length $path; - foreach my $action ( @{ $self->_paths->{$path} || [] } ) { + my @actions = @{ $self->_paths->{$path} || [] }; + + foreach my $action ( @actions ) { next unless $action->match($c); $c->req->action($path); $c->req->match($path); @@ -115,9 +117,9 @@ sub register_path { $path = '/' unless length $path; $path = URI->new($path)->canonical; - unshift( @{ $self->_paths->{$path} ||= [] }, $action); - - $self->_paths->{$path} = [ sort @{ $self->_paths->{$path} } ]; + $self->_paths->{$path} = [ + sort { $a <=> $b } ($action, @{ $self->_paths->{$path} || [] }) + ]; return 1; } diff --git a/t/aggregate/live_component_controller_action_index_or_default.t b/t/aggregate/live_component_controller_action_index_or_default.t index d385add..fada74b 100644 --- a/t/aggregate/live_component_controller_action_index_or_default.t +++ b/t/aggregate/live_component_controller_action_index_or_default.t @@ -27,6 +27,5 @@ else { sub run_tests { is(get('/indexchained'), 'index_chained', ':Chained overrides index'); is(get('/indexprivate'), 'index_private', 'index : Private still works'); - is(get('/defaultandpath/path_one_arg'), 'path_one_arg', - 'Path overrides default'); + is(get('/one_arg'), 'path_one_arg', ':Path overrides default'); } diff --git a/t/lib/TestAppIndexDefault/Controller/DefaultAndPath.pm b/t/lib/TestAppIndexDefault/Controller/Root.pm similarity index 71% rename from t/lib/TestAppIndexDefault/Controller/DefaultAndPath.pm rename to t/lib/TestAppIndexDefault/Controller/Root.pm index 385361c..8acebf8 100644 --- a/t/lib/TestAppIndexDefault/Controller/DefaultAndPath.pm +++ b/t/lib/TestAppIndexDefault/Controller/Root.pm @@ -1,7 +1,9 @@ -package TestAppIndexDefault::Controller::DefaultAndPath; +package TestAppIndexDefault::Controller::Root; use base 'Catalyst::Controller'; +__PACKAGE__->config->{namespace} = ''; + sub default : Private { my ($self, $c) = @_; $c->res->body('default');