mro compat stuff
[catagits/Catalyst-Runtime.git] / lib / Catalyst / DispatchType / Index.pm
CommitLineData
bcccee4e 1package Catalyst::DispatchType::Index;
2
6f1f968a 3use MRO::Compat;
4use mro 'c3';
3c0186f2 5use Moose;
6extends 'Catalyst::DispatchType';
0fc2d522 7no Moose;
e8b9f2a9 8
bcccee4e 9=head1 NAME
10
11Catalyst::DispatchType::Index - Index DispatchType
12
13=head1 SYNOPSIS
14
15See L<Catalyst>.
16
17=head1 DESCRIPTION
18
19=head1 METHODS
20
b5ecfcf0 21=head2 $self->match( $c, $path )
bcccee4e 22
4ab87e27 23Check if there's an index action for a given path, and set it up to use it
b2b90ec2 24if there is; only matches a full URI - if $c->req->args is already set
25this DispatchType is guaranteed not to match.
4ab87e27 26
bcccee4e 27=cut
28
29sub match {
30 my ( $self, $c, $path ) = @_;
bcccee4e 31 return if @{ $c->req->args };
a9dc674c 32 my $result = $c->get_action( 'index', $path );
bcccee4e 33
4082e678 34 if ($result && $result->match($c)) {
b5ecfcf0 35 $c->action($result);
a9dc674c 36 $c->namespace( $result->namespace );
bcccee4e 37 $c->req->action('index');
38 $c->req->match( $c->req->path );
39 return 1;
40 }
41 return 0;
42}
43
ea0e58d9 44=head2 $self->uri_for_action( $action, $captures )
45
46get a URI part for an action; always returns undef is $captures is set
47since index actions don't have captures
48
49=cut
50
51sub uri_for_action {
52 my ( $self, $action, $captures ) = @_;
53
54 return undef if @$captures;
55
56 return undef unless $action->name eq 'index';
57
58 return "/".$action->namespace;
59}
60
bcccee4e 61=head1 AUTHOR
62
63Sebastian Riedel, C<sri@cpan.org>
64
65=head1 COPYRIGHT
66
67This program is free software, you can redistribute it and/or modify it under
68the same terms as Perl itself.
69
70=cut
71
e5ecd5bc 72__PACKAGE__->meta->make_immutable;
73
bcccee4e 741;