| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | use Moose; | 
| 3 | 154 |  |  | 154 |  | 3231 | extends 'Catalyst::DispatchType'; | 
|  | 154 |  |  |  |  | 417 |  | 
|  | 154 |  |  |  |  | 1125 |  | 
| 4 |  |  |  |  |  |  | use namespace::clean -except => 'meta'; | 
| 5 | 154 |  |  | 154 |  | 1010423 |  | 
|  | 154 |  |  |  |  | 429 |  | 
|  | 154 |  |  |  |  | 1715 |  | 
| 6 |  |  |  |  |  |  | =head1 NAME | 
| 7 |  |  |  |  |  |  |  | 
| 8 |  |  |  |  |  |  | Catalyst::DispatchType::Index - Index DispatchType | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | See L<Catalyst::DispatchType>. | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | Dispatch type managing behaviour for index pages.  For more information on | 
| 17 |  |  |  |  |  |  | dispatch types, see: | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =over 4 | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =item * L<Catalyst::Manual::Intro> for how they affect application authors | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =item * L<Catalyst::DispatchType> for implementation information. | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =back | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | =cut | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | has _actions => ( | 
| 30 |  |  |  |  |  |  | is => 'rw', isa => 'HashRef', default => sub { +{} } | 
| 31 |  |  |  |  |  |  | ); | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =head1 METHODS | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | =head2 $self->match( $c, $path ) | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | Check if there's an index action for a given path, and set it up to use it | 
| 38 |  |  |  |  |  |  | if there is; only matches a full URI - if $c->req->args is already set | 
| 39 |  |  |  |  |  |  | this DispatchType is guaranteed not to match. | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | =cut | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | my ( $self, $c, $path ) = @_; | 
| 44 |  |  |  |  |  |  | return if @{ $c->req->args }; | 
| 45 | 1399 |  |  | 1399 | 1 | 4165 | my $result = $c->get_action( 'index', $path ); | 
| 46 | 1399 | 100 |  |  |  | 2533 |  | 
|  | 1399 |  |  |  |  | 4685 |  | 
| 47 | 922 |  |  |  |  | 4784 | return 0 unless $result && exists $self->_actions->{ $result->reverse }; | 
| 48 |  |  |  |  |  |  |  | 
| 49 | 922 | 100 | 100 |  |  | 6402 | if ($result && $result->match($c)) { | 
| 50 |  |  |  |  |  |  | $c->action($result); | 
| 51 | 27 | 50 | 33 |  |  | 112 | $c->namespace( $result->namespace ); | 
| 52 | 27 |  |  |  |  | 773 | $c->req->action('index'); | 
| 53 | 27 |  |  |  |  | 774 | $c->req->match( $c->req->path ); | 
| 54 | 27 |  |  |  |  | 97 | return 1; | 
| 55 | 27 |  |  |  |  | 95 | } | 
| 56 | 27 |  |  |  |  | 168 | return 0; | 
| 57 |  |  |  |  |  |  | } | 
| 58 | 0 |  |  |  |  | 0 |  | 
| 59 |  |  |  |  |  |  | =head2 $self->register( $c, $action ) | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | Register an action with this DispatchType. | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | =cut | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | my ( $self, $c, $action ) = @_; | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | $self->_actions->{ $action->reverse } = $action if $action->name eq 'index'; | 
| 68 | 44574 |  |  | 44574 | 1 | 92703 |  | 
| 69 |  |  |  |  |  |  | return 1; | 
| 70 | 44574 | 100 |  |  |  | 1126500 | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 | 44574 |  |  |  |  | 117458 | =head2 $self->uri_for_action( $action, $captures ) | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | get a URI part for an action; always returns undef is $captures is set | 
| 75 |  |  |  |  |  |  | since index actions don't have captures | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | =cut | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | my ( $self, $action, $captures ) = @_; | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | return undef if @$captures; | 
| 82 |  |  |  |  |  |  |  | 
| 83 | 78 |  |  | 78 | 1 | 215 | return undef unless exists $self->_actions->{ $action->reverse }; | 
| 84 |  |  |  |  |  |  |  | 
| 85 | 78 | 100 |  |  |  | 265 | return "/".$action->namespace; | 
| 86 |  |  |  |  |  |  | } | 
| 87 | 29 | 100 |  |  |  | 899 |  | 
| 88 |  |  |  |  |  |  |  | 
| 89 | 1 |  |  |  |  | 28 | =head1 AUTHORS | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | Catalyst Contributors, see Catalyst.pm | 
| 92 | 74057 |  |  | 74057 |  | 172843 |  | 
| 93 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | This library is free software. You can redistribute it and/or modify it under | 
| 96 |  |  |  |  |  |  | the same terms as Perl itself. | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | =cut | 
| 99 |  |  |  |  |  |  |  | 
| 100 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 101 |  |  |  |  |  |  |  | 
| 102 |  |  |  |  |  |  | 1; |