authors cleanup
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Default.pm
CommitLineData
b96f127f 1package Catalyst::DispatchType::Default;
2
3use strict;
4use base qw/Catalyst::DispatchType/;
5
2633d7dc 6=head1 NAME
7
8Catalyst::DispatchType::Default - Default DispatchType
9
10=head1 SYNOPSIS
11
12See L<Catalyst>.
13
14=head1 DESCRIPTION
15
16=head1 METHODS
17
b5ecfcf0 18=head2 $self->match( $c, $path )
2633d7dc 19
b2b90ec2 20If path is empty (i.e. all path parts have been converted into args),
21attempts to find a default for the namespace constructed from the args,
22or the last inherited default otherwise and will match that.
23
24If path is not empty, never matches since Default will only match if all
25other possibilities have been exhausted.
4ab87e27 26
2633d7dc 27=cut
28
29sub match {
78d760bb 30 my ( $self, $c, $path ) = @_;
31 return if $path =~ m!/!; # Not at root yet, wait for it ...
6112c0f9 32 my $result = ( $c->get_actions( 'default', $c->req->path ) )[-1];
78d760bb 33
34 # Find default on namespace or super
4082e678 35 if ($result && $result->match($c)) {
6112c0f9 36 $c->action($result);
a9dc674c 37 $c->namespace( $result->namespace );
b96f127f 38 $c->req->action('default');
6112c0f9 39
7cfcfd27 40 # default methods receive the controller name as the first argument
6112c0f9 41 unshift @{ $c->req->args }, $path if $path;
b96f127f 42 $c->req->match('');
22f3a8dd 43 return 1;
b96f127f 44 }
22f3a8dd 45 return 0;
b96f127f 46}
47
0bf7ab71 48=head1 AUTHORS
2633d7dc 49
0bf7ab71 50Catalyst Contributors, see Catalyst.pm
2633d7dc 51
52=head1 COPYRIGHT
53
54This program is free software, you can redistribute it and/or modify it under
55the same terms as Perl itself.
56
57=cut
58
b96f127f 591;