| 1 | package Mason::Plugin::PSGIHandler::Request; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | $Mason::Plugin::PSGIHandler::Request::VERSION = '0.06'; | |||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Mason::Plack::Response; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Mason::PluginRole; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | has 'req' => ( is => 'ro', required => 1, isa => 'Object' ); | |||||||||||||||||||||||||||
| 10 | 1 | has 'res' => ( is => 'ro', lazy_build => 1 ); | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | method _build_res () { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_build_res: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 5 | return Mason::Plack::Response->new(); | |||||||||||||||||||||||||||
| 14 | 1 | } | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 7 | ▶ | around 'run' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 17 | 7 | my $orig = shift; | |||||||||||||||||||||||||||
| 18 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 7 | my $result = $self->$orig(@_); | |||||||||||||||||||||||||||
| 21 | 5 | ▶ | $self->res->status(200) if !$self->res->status; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 5 | $self->res->content( $result->output ); | |||||||||||||||||||||||||||
| 23 | 5 | $result->plack_response( $self->res ); | |||||||||||||||||||||||||||
| 24 | 5 | return $result; | |||||||||||||||||||||||||||
| 25 | 1 | }; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 6 | ▶ | around 'construct_page_component' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||
| 28 | 6 | my $orig = shift; | |||||||||||||||||||||||||||
| 29 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | 6 | my ( $compc, $args ) = @_; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 6 | ▶ | if ( blessed($args) && $args->can('get_all') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($args) and $args->can("get_all")
MC/DC0%0/2
builtin::blessed($args) and $args->can("get_all")
builtin::blessed($args)
$args->can("get_all")
Truth table33%1/3
A and B
A= builtin::blessed($args)B= $args->can("get_all")
| |||||||||||||||||||||||||||||
| 33 | 6 | my $orig_args = $args; | |||||||||||||||||||||||||||
| 34 | 6 | $args = $orig_args->as_hashref; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # TODO: cache this | ||||||||||||||||||||||||||||
| 37 | my @array_attrs = | ||||||||||||||||||||||||||||
| 38 | 2 | map { $_->name } | |||||||||||||||||||||||||||
| 39 | 6 | ▶ | grep { $_->has_type_constraint && $_->type_constraint->is_a_type_of('ArrayRef') } | ||||||||||||||||||||||||||
|
Condition100%3/3
$_->has_type_constraint && $_->type_constraint->is_a_type_of('ArrayRef')
MC/DC100%2/2
$_->has_type_constraint && $_->type_constraint->is_a_type_of('ArrayRef')
$_->has_type_constraint
$_->type_constraint->is_a_type_of('ArrayRef')
Truth table100%3/3
A && B
A= $_->has_type_constraintB= $_->type_constraint->is_a_type_of('ArrayRef')
| |||||||||||||||||||||||||||||
| 40 | $compc->meta->get_all_attributes; | ||||||||||||||||||||||||||||
| 41 | 6 | foreach my $attr (@array_attrs) { | |||||||||||||||||||||||||||
| 42 | 2 | $args->{$attr} = [ $orig_args->get_all($attr) ]; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 6 | $self->$orig( $compc, $args ); | |||||||||||||||||||||||||||
| 47 | 1 | }; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 6 | ▶ | override 'catch_abort' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 50 | 6 | my ( $self, $code ) = @_; | |||||||||||||||||||||||||||
| 51 | 6 | my $retval; | |||||||||||||||||||||||||||
| 52 | 6 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 6 | $retval = $code->(); | |||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | 4 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 56 | 4 | my $err = $_; | |||||||||||||||||||||||||||
| 57 | 4 | ▶ | if ( $self->aborted($err) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 3 | $retval = $err->aborted_value; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | else { | ||||||||||||||||||||||||||||
| 61 | 1 | local $SIG{__DIE__} = undef; | |||||||||||||||||||||||||||
| 62 | 1 | die $err; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | 6 | }; | |||||||||||||||||||||||||||
| 65 | 5 | return $retval; | |||||||||||||||||||||||||||
| 66 | 1 | }; | |||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 3 | ▶ | before 'abort' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 69 | 3 | my ( $self, $retval ) = @_; | |||||||||||||||||||||||||||
| 70 | 3 | ▶ | $self->res->status($retval) if defined($retval); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | 1 | }; | |||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 1 | ▶ | method redirect () { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
redirect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 74 | 2 | $self->res->redirect(@_); | |||||||||||||||||||||||||||
| 75 | 2 | $self->clear_and_abort(); | |||||||||||||||||||||||||||
| 76 | 1 | } | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | method not_found () { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
Subroutine
__ANON__: not called CC=1 SCAR=4.1
| |||||||||||||||||||||||||||||
| 79 | 0 | $self->res->status(404); | |||||||||||||||||||||||||||
| 80 | 0 | $self->clear_and_abort(); | |||||||||||||||||||||||||||
| 81 | 1 | } | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 1 | 1; | |||||||||||||||||||||||||||