| 1 | package Reaction::UI::Controller::Role::RedirectTo; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 4 | ▶ | use Moose::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 0 | ▶ | sub redirect_to { | ||||||||||||||||||
|
Subroutine
redirect_to: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||
| 6 | 0 | my ($self, $c, $to, $cap, $args, $attrs) = @_; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 0 | $c->log->debug( | |||||||||||||||||||
| 9 | "Using redirect_to is now deprecated and may be removed in the future." | ||||||||||||||||||||
| 10 | ); | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | #the confess calls could be changed later to $c->log ? | ||||||||||||||||||||
| 13 | 0 | my $action; | |||||||||||||||||||
| 14 | 0 | my $reftype = ref($to); | |||||||||||||||||||
| 15 | 0 | ▶ | if( $reftype eq '' ){ | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 16 | 0 | $action = $self->action_for($to); | |||||||||||||||||||
| 17 | 0 | ▶ | confess("Failed to locate action ${to} in " . blessed($self)) unless $action; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | ▶ | } elsif($reftype eq 'ARRAY' && @$to == 2){ #is that overkill / too strict? | |||||||||||||||||||
|
Condition0%0/3
$reftype eq "ARRAY" and @$to == 2
MC/DC0%0/2
$reftype eq "ARRAY" and @$to == 2
$reftype eq "ARRAY"
@$to == 2
Truth table0%0/3
A and B
A= $reftype eq "ARRAY"B= @$to == 2
| |||||||||||||||||||||
| 19 | 0 | $action = $c->controller($to->[0])->action_for($to->[1]); | |||||||||||||||||||
| 20 | 0 | ▶ | confess("Failed to locate action $to->[1] in $to->[0]" ) unless $action; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | ▶ | } elsif( blessed $to && $to->isa('Catalyst::Action') ){ | |||||||||||||||||||
|
Condition0%0/3
builtin::blessed($to) and $to->isa("Catalyst::Action")
MC/DC0%0/2
builtin::blessed($to) and $to->isa("Catalyst::Action")
builtin::blessed($to)
$to->isa("Catalyst::Action")
Truth table0%0/3
A and B
A= builtin::blessed($to)B= $to->isa("Catalyst::Action")
| |||||||||||||||||||||
| 22 | 0 | $action = $to; | |||||||||||||||||||
| 23 | } else{ | ||||||||||||||||||||
| 24 | 0 | confess("Failed to locate action from ${to}"); | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | $cap ||= $c->req->captures; | ||||||||||||||||||
|
Condition0%0/3
$cap ||= $c->req->captures
MC/DC0%0/2
$cap ||= $c->req->captures
$cap
$c->req->captures
Truth table0%0/3
A ||= B
A= $capB= $c->req->captures
| |||||||||||||||||||||
| 28 | 0 | ▶ | $args ||= $c->req->args; | ||||||||||||||||||
|
Condition0%0/3
$args ||= $c->req->args
MC/DC0%0/2
$args ||= $c->req->args
$args
$c->req->args
Truth table0%0/3
A ||= B
A= $argsB= $c->req->args
| |||||||||||||||||||||
| 29 | 0 | ▶ | $attrs ||= {}; | ||||||||||||||||||
|
Condition0%0/2
$attrs ||= {}
MC/DC0%0/1
$attrs ||= {}
$attrs
Truth table0%0/2
A
A= $attrs
| |||||||||||||||||||||
| 30 | 0 | my $uri = $c->uri_for($action, $cap, @$args, $attrs); | |||||||||||||||||||
| 31 | 0 | $c->res->redirect($uri); | |||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 4 | 1; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | __END__; | ||||||||||||||||||||