| 1 | package Catalyst::View::BasePerRequest::Lifecycle::Request; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Module::Runtime (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | has 'class' => (is=>'ro', required=>1); | |||||||||||||||||||||||||||
| 8 | 1 | has 'app' => (is=>'ro', required=>1); | |||||||||||||||||||||||||||
| 9 | 1 | has 'merged_args' => (is=>'ro', required=>1); | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 13 | ▶ | sub ACCEPT_CONTEXT { | ||||||||||||||||||||||||||
|
Subroutine
ACCEPT_CONTEXT: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 13 | my ($factory, $c, @args) = @_; | |||||||||||||||||||||||||||
| 13 | 13 | ▶ | return $factory unless ref($c); # Return the factory if called in application context | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | 12 | ▶ | my $key = Scalar::Util::refaddr($factory) || $factory; | ||||||||||||||||||||||||||
|
Condition33%1/3
builtin::refaddr($factory) || $factory
MC/DC0%0/2
builtin::refaddr($factory) || $factory
builtin::refaddr($factory)
$factory
Truth table33%1/3
A || B
A= builtin::refaddr($factory)B= $factory
| |||||||||||||||||||||||||||||
| 15 | 12 | ▶ | return $c->stash->{"__BasePerRequest_${key}"} ||= $factory->build($c, @args); | ||||||||||||||||||||||||||
|
Condition33%1/3
$c->stash->{"__BasePerRequest_$key"} ||= $factory->build($c, @args)
MC/DC0%0/2
$c->stash->{"__BasePerRequest_$key"} ||= $factory->build($c, @args)
$c->stash->{"__BasePerRequest_$key"}
$factory->build($c, @args)
Truth table33%1/3
A ||= B
A= $c->stash->{"__BasePerRequest_$key"}B= $factory->build($c, @args)
| |||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 12 | ▶ | sub build { | ||||||||||||||||||||||||||
|
Subroutine
build: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | 12 | my ($factory, $c, @args) = @_; | |||||||||||||||||||||||||||
| 20 | 12 | my $class = $factory->class; | |||||||||||||||||||||||||||
| 21 | 12 | ▶ | @args = $class->prepare_build_args($c, @args) if $class->can('prepare_build_args'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 12 | my %build_args = $factory->prepare_build_args($c, @args); | |||||||||||||||||||||||||||
| 23 | my $view = eval { | ||||||||||||||||||||||||||||
| 24 | 12 | $class->build(%build_args); | |||||||||||||||||||||||||||
| 25 | 12 | ▶ | } || do { | ||||||||||||||||||||||||||
|
Condition33%1/3
eval {
do {
$class->build(%build_args)
}
} || do {
$factory->do_handle_build_view_exception($class, $@)
}
MC/DC0%0/2
eval {
do {
$class->build(%build_args)
}
} || do {
$factory->do_handle_build_view_exception($class, $@)
}
eval {
do {
$class->build(%build_args)
}
}
do {
$factory->do_handle_build_view_exception($class, $@)
}
Truth table33%1/3
A || B
A= eval {
do {
$class->build(%build_args)
}
}B= do {
$factory->do_handle_build_view_exception($class, $@)
}
| |||||||||||||||||||||||||||||
| 26 | 0 | $factory->do_handle_build_view_exception($class, $@); | |||||||||||||||||||||||||||
| 27 | }; | ||||||||||||||||||||||||||||
| 28 | 12 | $c->stash(current_view_instance=>$view); | |||||||||||||||||||||||||||
| 29 | 12 | return $view; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | ▶ | sub build_view_error_class { return 'Catalyst::View::BasePerRequest::Exception::BuildViewError' } | ||||||||||||||||||||||||||
|
Subroutine
build_view_error_class: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub do_handle_build_view_exception { | ||||||||||||||||||||||||||
|
Subroutine
do_handle_build_view_exception: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 0 | my ($factory, $class, $err) = @_; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | return $err->rethrow if Scalar::Util::blessed($err) && $err->can('rethrow'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($err) and $err->can("rethrow")
MC/DC0%0/2
builtin::blessed($err) and $err->can("rethrow")
builtin::blessed($err)
$err->can("rethrow")
Truth table0%0/3
A and B
A= builtin::blessed($err)B= $err->can("rethrow")
| |||||||||||||||||||||||||||||
| 37 | 0 | my $exception = Module::Runtime::use_module($factory->build_view_error_class); | |||||||||||||||||||||||||||
| 38 | 0 | $exception->throw(class=>$class, build_error=>$err); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 12 | ▶ | sub prepare_build_args { | ||||||||||||||||||||||||||
|
Subroutine
prepare_build_args: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 42 | 12 | my ($factory, $c, @args) = @_; | |||||||||||||||||||||||||||
| 43 | 12 | my %args = $factory->prepare_args(@args); | |||||||||||||||||||||||||||
| 44 | 12 | ▶ | my %merged_args = %{$factory->merged_args||+{}}; | ||||||||||||||||||||||||||
|
Condition50%1/2
$factory->merged_args || {}
MC/DC0%0/1
$factory->merged_args || {}
$factory->merged_args
Truth table50%1/2
A
A= $factory->merged_args
| |||||||||||||||||||||||||||||
| 45 | 12 | return (%merged_args, %args, app=>$factory->app, ctx=>$c); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 12 | ▶ | sub prepare_args { | ||||||||||||||||||||||||||
|
Subroutine
prepare_args: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 12 | my ($factory, @args) = @_; | |||||||||||||||||||||||||||
| 50 | 12 | ▶ | if( (ref($args[-1])||'') eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
ref $args[-1] || ''
MC/DC100%1/1
ref $args[-1] || ''
ref $args[-1]
Truth table100%2/2
A
A= ref $args[-1]
| |||||||||||||||||||||||||||||
| 51 | 6 | my $code = pop @args; | |||||||||||||||||||||||||||
| 52 | 6 | push @args, (code=>$code); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 12 | return @args; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 1 | 1; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 NAME | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | Catalyst::View::BasePerRequest::Lifecycle::Request - Build a per request view | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | Not intended for standalone enduser use. | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | This module is used by L<Catalyst::View::BasePerRequest> to encapsulate building the actual | ||||||||||||||||||||||||||||
| 70 | view object on a per request basis. Code here might be of interest to people building their | ||||||||||||||||||||||||||||
| 71 | own view frameworks. for example you might wish to override the exception handler or change | ||||||||||||||||||||||||||||
| 72 | how the initialization arguments are made. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head1 ALSO SEE | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | L<Catalyst::View::BasePerRequest> | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 AUTHORS & COPYRIGHT | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | See L<Catalyst::View::BasePerRequest> | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | See L<Catalyst::View::BasePerRequest> | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||