| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  |  | 
| 2 |  |  |  |  |  |  | use warnings; | 
| 3 | 1 |  |  | 1 |  | 583 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 35 |  | 
| 4 | 1 |  |  | 1 |  | 5 | use Scalar::Util (); | 
|  | 1 |  |  |  |  | 28 |  | 
|  | 1 |  |  |  |  | 27 |  | 
| 5 | 1 |  |  | 1 |  | 6 | use Module::Runtime (); | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 15 |  | 
| 6 | 1 |  |  | 1 |  | 6 |  | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 418 |  | 
| 7 |  |  |  |  |  |  | my ($factory, $c, @args) = @_; | 
| 8 |  |  |  |  |  |  | my $key = Scalar::Util::refaddr($factory) || $factory; | 
| 9 | 13 |  |  | 13 | 0 | 108343 | return $c->stash->{"__BasePerRequest_${key}"} ||= $factory->build($c, @args); | 
| 10 | 13 |  | 33 |  |  | 46 | } | 
| 11 | 13 |  | 66 |  |  | 63 |  | 
| 12 |  |  |  |  |  |  | my ($factory, $c, @args) = @_; | 
| 13 |  |  |  |  |  |  | my $class = $factory->{class}; | 
| 14 |  |  |  |  |  |  | @args = $class->prepare_build_args($c, @args) if $class->can('prepare_build_args'); | 
| 15 | 12 |  |  | 12 | 0 | 745 | my %build_args = $factory->prepare_build_args($c, @args); | 
| 16 | 12 |  |  |  |  | 47 | my $view = eval { | 
| 17 | 12 | 100 |  |  |  | 142 | $class->build(%build_args); | 
| 18 | 12 |  |  |  |  | 77 | } || do { | 
| 19 |  |  |  |  |  |  | $factory->do_handle_build_view_exception($class, $@); | 
| 20 |  |  |  |  |  |  | }; | 
| 21 | 12 |  | 33 |  |  | 22 | $c->stash(current_view_instance=>$view); | 
| 22 |  |  |  |  |  |  | return $view; | 
| 23 |  |  |  |  |  |  | } | 
| 24 | 12 |  |  |  |  | 901 |  | 
| 25 | 12 |  |  |  |  | 795 |  | 
| 26 |  |  |  |  |  |  | my ($factory, $class, $err) = @_; | 
| 27 |  |  |  |  |  |  | return $err->rethrow if Scalar::Util::blessed($err) && $err->can('rethrow'); | 
| 28 | 0 |  |  | 0 | 0 | 0 | my $exception = Module::Runtime::use_module($factory->build_view_error_class); | 
| 29 |  |  |  |  |  |  | $exception->throw(class=>$class, build_error=>$err); | 
| 30 |  |  |  |  |  |  | } | 
| 31 | 0 |  |  | 0 | 0 | 0 |  | 
| 32 | 0 | 0 | 0 |  |  | 0 | my ($factory, $c, @args) = @_; | 
| 33 | 0 |  |  |  |  | 0 | my %args = $factory->prepare_args(@args); | 
| 34 | 0 |  |  |  |  | 0 | my %merged_args = %{$factory->{merged_args}||+{}}; | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | return (%merged_args, %args, ctx=>$c); | 
| 37 |  |  |  |  |  |  | } | 
| 38 | 12 |  |  | 12 | 0 | 33 |  | 
| 39 | 12 |  |  |  |  | 26 | my ($factory, @args) = @_; | 
| 40 | 12 | 50 |  |  |  | 21 | if( (ref($args[-1])||'') eq 'CODE' ) { | 
|  | 12 |  |  |  |  | 67 |  | 
| 41 |  |  |  |  |  |  | my $code = pop @args; | 
| 42 | 12 |  |  |  |  | 69 | push @args, (code=>$code); | 
| 43 |  |  |  |  |  |  | } | 
| 44 |  |  |  |  |  |  | return @args; | 
| 45 |  |  |  |  |  |  | } | 
| 46 | 12 |  |  | 12 | 0 | 26 |  | 
| 47 | 12 | 100 | 100 |  |  | 60 | 1; | 
| 48 | 6 |  |  |  |  | 9 |  | 
| 49 | 6 |  |  |  |  | 13 | =head1 NAME | 
| 50 |  |  |  |  |  |  |  | 
| 51 | 12 |  |  |  |  | 34 | Catalyst::View::Template::BasePerRequest::Factory - Build a per request view | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | Not intended for standalone enduser use. | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | This module is used by L<Catalyst::View::BasePerRequest> to encapsulate building the actual | 
| 60 |  |  |  |  |  |  | view object on a per request basis.  Code here might be of interest to people building their | 
| 61 |  |  |  |  |  |  | own view frameworks.  for example you might wish to override the exception handler or change | 
| 62 |  |  |  |  |  |  | how the initialization arguments are made. | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =head1 ALSO SEE | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | L<Catalyst::View::BasePerRequest> | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | =head1 AUTHORS & COPYRIGHT | 
| 69 |  |  |  |  |  |  |  | 
| 70 |  |  |  |  |  |  | See L<Catalyst::View::BasePerRequest> | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | =head1 LICENSE | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | See L<Catalyst::View::BasePerRequest> | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | =cut |