| 1 | package Catalyst::DispatchType::Index; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 154 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 154 | extends 'Catalyst::DispatchType'; | |||||||||||||||||||||||||||
| 5 | 154 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Catalyst::DispatchType::Index - Index DispatchType | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | See L<Catalyst::DispatchType>. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Dispatch type managing behaviour for index pages. For more information on | ||||||||||||||||||||||||||||
| 18 | dispatch types, see: | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =over 4 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =item * L<Catalyst::Manual::Intro> for how they affect application authors | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | =item * L<Catalyst::DispatchType> for implementation information. | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | =back | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | has _actions => ( | ||||||||||||||||||||||||||||
| 31 | 163 | ▶ | is => 'rw', isa => 'HashRef', default => sub { +{} } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 32 | 154 | ); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 METHODS | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | =head2 $self->match( $c, $path ) | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | Check if there's an index action for a given path, and set it up to use it | ||||||||||||||||||||||||||||
| 39 | if there is; only matches a full URI - if $c->req->args is already set | ||||||||||||||||||||||||||||
| 40 | this DispatchType is guaranteed not to match. | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =cut | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1408 | ▶ | sub match { | ||||||||||||||||||||||||||
|
Subroutine
match: called CC=6 SCAR=18.2
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 1408 | my ( $self, $c, $path ) = @_; | |||||||||||||||||||||||||||
| 46 | 1408 | ▶ | return if @{ $c->req->args }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 931 | my $result = $c->get_action( 'index', $path ); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 931 | ▶ | return 0 unless $result && exists $self->_actions->{ $result->reverse }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$result and exists $self->_actions->{$result->reverse}
MC/DC100%2/2
$result and exists $self->_actions->{$result->reverse}
$result
exists $self->_actions->{$result->reverse}
Truth table100%3/3
A and B
A= $resultB= exists $self->_actions->{$result->reverse}
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 27 | ▶ | if ($result && $result->match($c)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$result and $result->match($c)
MC/DC0%0/2
$result and $result->match($c)
$result
$result->match($c)
Truth table33%1/3
A and B
A= $resultB= $result->match($c)
| |||||||||||||||||||||||||||||
| 52 | 27 | $c->action($result); | |||||||||||||||||||||||||||
| 53 | 27 | $c->namespace( $result->namespace ); | |||||||||||||||||||||||||||
| 54 | 27 | $c->req->action('index'); | |||||||||||||||||||||||||||
| 55 | 27 | $c->req->match( $c->req->path ); | |||||||||||||||||||||||||||
| 56 | 27 | return 1; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 0 | return 0; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head2 $self->register( $c, $action ) | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Register an action with this DispatchType. | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 40039 | ▶ | sub register { | ||||||||||||||||||||||||||
|
Subroutine
register: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 68 | 40039 | my ( $self, $c, $action ) = @_; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 40039 | ▶ | $self->_actions->{ $action->reverse } = $action if $action->name eq 'index'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 40039 | return 1; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head2 $self->uri_for_action( $action, $captures ) | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | get a URI part for an action; always returns undef is $captures is set | ||||||||||||||||||||||||||||
| 78 | since index actions don't have captures | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =cut | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 78 | ▶ | sub uri_for_action { | ||||||||||||||||||||||||||
|
Subroutine
uri_for_action: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 83 | 78 | my ( $self, $action, $captures ) = @_; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 78 | ▶ | return undef if @$captures; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 29 | ▶ | return undef unless exists $self->_actions->{ $action->reverse }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 1 | return "/".$action->namespace; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 66250 | ▶ | sub _is_low_precedence { 1 } | ||||||||||||||||||||||||||
|
Subroutine
_is_low_precedence: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head1 AUTHORS | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Catalyst Contributors, see Catalyst.pm | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | This library is free software. You can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 101 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | =cut | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 154 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 154 | 1; | |||||||||||||||||||||||||||