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<Args> 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.
$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);
$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;
}
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');
}
-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');