added docs for engine/dispatcher
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Default.pm
1 package Catalyst::DispatchType::Default;
2
3 use strict;
4 use base qw/Catalyst::DispatchType/;
5
6 =head1 NAME
7
8 Catalyst::DispatchType::Default - Default DispatchType
9
10 =head1 SYNOPSIS
11
12 See L<Catalyst>.
13
14 =head1 DESCRIPTION
15
16 =head1 METHODS
17
18 =head2 $self->match( $c, $path )
19
20 Check if default action matches, and set action if it does. 
21 Will be called last for each controller.
22
23 =cut
24
25 sub match {
26     my ( $self, $c, $path ) = @_;
27     return if $path =~ m!/!;    # Not at root yet, wait for it ...
28     my $result = ( $c->get_actions( 'default', $c->req->path ) )[-1];
29
30     # Find default on namespace or super
31     if ($result && $result->match($c)) {
32         $c->action($result);
33         $c->namespace( $result->namespace );
34         $c->req->action('default');
35
36         # default methods receive the controller name as the first argument
37         unshift @{ $c->req->args }, $path if $path;
38         $c->req->match('');
39         return 1;
40     }
41     return 0;
42 }
43
44 =head1 AUTHOR
45
46 Matt S Trout
47 Sebastian Riedel, C<sri@cpan.org>
48
49 =head1 COPYRIGHT
50
51 This program is free software, you can redistribute it and/or modify it under
52 the same terms as Perl itself.
53
54 =cut
55
56 1;