blib/lib/Mason/Request.pm

filter: Statementstmt 97.4% 414 / 425 Branchbran 80.0% 40 / 50 Conditioncond 61.1% 11 / 18 MC/DCmcdc 41.6% 5 / 12 Subroutinesub 96.6% 114 / 118 Podpod n/a totaltotal 93.7% 584 / 623 CC 64 SCAR 8.2
CC
64
Cov
94%
__ANON__
8.0
_apply_one_filter
8.0
__ANON__
6.0
CRAP 2.3
« blib/lib/Mason.pm ↑ Summary blib/lib/Mason/Plugin/LvalueAttributes/Interp.pm »
1 package Mason::Request;
2 22 $Mason::Request::VERSION = '2.24';
3 22 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 22 ▶use Guard;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 22 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 22 ▶use Mason::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 22 ▶use Mason::TieHandle;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 22 ▶use Mason::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 22 ▶use Mason::Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use Scalar::Util qw(blessed reftype weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 22 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 114 ▶my $default_out = sub { my ( $text, $self ) = @_; $self->result->_append_output($text) };
Subroutine __ANON__: called CC=1 SCAR=0.0
15 22 my $next_id = 0;
16  
17 # Passed attributes
18 #
19 22 has 'interp' => ( required => 1, weak_ref => 1 );
20 176 ▶has 'out_method' => ( isa => 'Mason::Types::OutMethod', default => sub { $default_out }, coerce => 1 );
Subroutine __ANON__: called CC=1 SCAR=0.0
21  
22 # Derived attributes
23 #
24 187 ▶has 'buffer_stack' => ( init_arg => undef, default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
25 22 has 'declined' => ( init_arg => undef, is => 'rw' );
26 187 ▶has 'declined_paths' => ( default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
27 22 has 'go_result' => ( init_arg => undef );
28 187 ▶has 'id' => ( init_arg => undef, default => sub { $next_id++ } );
Subroutine __ANON__: called CC=1 SCAR=0.0
29 22 has 'output' => ( init_arg => undef, default => '' );
30 22 has 'page' => ( init_arg => undef );
31 22 has 'path_info' => ( init_arg => undef, default => '' );
32 22 has 'request_args' => ( init_arg => undef );
33 187 ▶has 'request_code_cache' => ( init_arg => undef, default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
34 22 has 'request_path' => ( init_arg => undef );
35 22 has 'result' => ( init_arg => undef, lazy_build => 1 );
36 22 has 'run_params' => ( init_arg => undef );
37  
38 # Globals, localized to each request
39 #
40 22 our ( $current_request, $current_buffer );
41 0 ▶method current_request () { $current_request }
Subroutine BEGIN: called CC=1 SCAR=0.5
Subroutine current_request: not called CC=1 SCAR=0.5
Subroutine __ANON__: called CC=1 SCAR=0.5
42  
43 #
44 # BUILD
45 #
46  
47 22 ▶method BUILD ($params) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine BUILD: called CC=1 SCAR=0.0
48  
49 # Make a copy of params sans interp
50 #
51 24 $self->{orig_request_params} = $params;
52 24 delete( $self->{orig_request_params}->{interp} );
53 22 }
54  
55 22 ▶method _build_result () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _build_result: called CC=1 SCAR=0.0
56 94 return $self->interp->result_class->new;
57 22 }
58  
59 #
60 # PUBLIC METHODS
61 #
62  
63 22 ▶method abort ($aborted_value) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine abort: called CC=1 SCAR=0.0
64 24 Mason::Exception::Abort->throw(
65 error => 'Request->abort was called',
66 aborted_value => $aborted_value
67 );
68 22 }
69  
70 22 ▶method aborted ($err) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine aborted: called CC=2 SCAR=6.9
71 26 ▶ return blessed($err) && $err->isa('Mason::Exception::Abort');
Condition100%3/3
builtin::blessed($err) && $err->isa('Mason::Exception::Abort')
!ll&&!rl&&r
4121
MC/DC100%2/2
builtin::blessed($err) && $err->isa('Mason::Exception::Abort')
builtin::blessed($err) $err->isa('Mason::Exception::Abort')
Truth table100%3/3
A && B
A= builtin::blessed($err)B= $err->isa('Mason::Exception::Abort')
ABresult
0X0
100
111
72 22 }
73  
74 22 ▶method add_cleanup ($code) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine add_cleanup: called CC=1 SCAR=0.0
75 1 push( @{ $self->{cleanups} }, $code );
76 22 }
77  
78 0 ▶method cache () {
Subroutine BEGIN: called CC=1 SCAR=2.6
Subroutine __ANON__: not called CC=1 SCAR=3.5
79 0 die 'caching is now in the cache plugin (Mason::Plugin::Cache)';
80 22 }
81  
82 22 ▶method capture ($code) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=3 SCAR=11.1
83 31 ▶ croak "capture() expects a code reference" unless defined($code) && ref($code) eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code and ref $code eq "CODE" 0 31 31
Condition33%1/3
defined $code and ref $code eq "CODE"
!ll&&!rl&&r
0031
MC/DC0%0/2
defined $code and ref $code eq "CODE"
defined $code ref $code eq "CODE"
Truth table33%1/3
A and B
A= defined $codeB= ref $code eq "CODE"
ABresult
0X0
100
111
84 31 my $output;
85 {
86 31 $self->_push_buffer;
87 31 ▶ scope_guard { $output = ${ $self->_current_buffer }; $self->_pop_buffer; };
Subroutine __ANON__: called CC=1 SCAR=0.0
88 31 $code->();
89 }
90 31 return $output;
91 22 }
92  
93 22 ▶method clear_and_abort () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine clear_and_abort: called CC=1 SCAR=0.0
94 21 $self->clear_buffer;
95 21 $self->abort(@_);
96 22 }
97  
98 22 ▶method clear_buffer () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine clear_buffer: called CC=2 SCAR=6.9
99 24 foreach my $buffer ( @{ $self->buffer_stack } ) {
100 24 $$buffer = '';
101 }
102 22 }
103  
104 22 ▶method comp () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
105 37 $self->construct(@_)->main();
106 22 }
107  
108 22 ▶method comp_exists ($path) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
109 6 return $self->interp->comp_exists( $self->rel_to_abs($path) );
110 22 }
111  
112 22 ▶method construct () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=7.0
113 37 my $path = shift;
114 37 ▶ my $compc = $self->load($path)
Branch: 2 branches
BranchTrueFalseTotal
my $compc = $self->load($path) or $self->_comp_not_found($path) 34 3 37
my $compc = $self->load($path) or $self->_comp_not_found($path) 0 5 5
115 or $self->_comp_not_found($path);
116 34 return $compc->new( @_, 'm' => $self );
117 22 }
118  
119 22 ▶method current_comp_class () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=4 SCAR=13.9
120 19 my $cnt = 1;
121 19 while (1) {
122 82 ▶ if ( my $pkg = ( caller($cnt) )[0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pkg = (&CORE::GLOBAL::caller($cnt))[0]) { } 81 1 82
123 81 ▶ return $pkg if $pkg->isa('Mason::Component') && $pkg ne 'Mason::Component';
Branch: 1 branch
BranchTrueFalseTotal
if $pkg->isa("Mason::Component") and $pkg ne "Mason::Component" 18 63 81
Condition66%4/6
$pkg->isa("Mason::Component") and $pkg ne "Mason::Component"
!ll&&!rl&&r
63018
$pkg->isa("Mason::Component") and $pkg ne "Mason::Component"
!ll&&!rl&&r
208
MC/DC50%1/2
$pkg->isa("Mason::Component") and $pkg ne "Mason::Component"
$pkg->isa("Mason::Component") $pkg ne "Mason::Component"
MC/DC50%1/2
$pkg->isa("Mason::Component") and $pkg ne "Mason::Component"
$pkg->isa("Mason::Component") $pkg ne "Mason::Component"
Truth table66%2/3
A and B
A= $pkg->isa("Mason::Component")B= $pkg ne "Mason::Component"
ABresult
0X0
100
111
Truth table66%2/3
A and B
A= $pkg->isa("Mason::Component")B= $pkg ne "Mason::Component"
ABresult
0X0
100
111
124 }
125 else {
126 1 confess("cannot determine current_comp_class from stack");
127 }
128 63 $cnt++;
129 }
130 22 }
131  
132 22 ▶method decline () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
133 21 $self->declined(1);
134 21 $self->clear_and_abort;
135 22 }
136  
137 22 ▶method filter () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine filter: called CC=1 SCAR=0.0
138 2 $self->_apply_filters(@_);
139 22 }
140  
141 22 ▶method flush_buffer () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine flush_buffer: called CC=2 SCAR=6.9
142 129 my $request_buffer = $self->_request_buffer;
143 129 $self->process_output($request_buffer);
144 129 ▶ $self->out_method->( $$request_buffer, $self )
Branch: 1 branch
BranchTrueFalseTotal
if length $$request_buffer 124 5 129
145 if length $$request_buffer;
146 129 $$request_buffer = '';
147 22 }
148  
149 22 ▶method go () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=6.9
150 3 $self->clear_buffer;
151 3 my %request_params = ( %{ $self->{orig_request_params} } );
152 3 ▶ if ( ref( $_[0] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "HASH") 1 2 3
153 1 %request_params = ( %request_params, %{ shift(@_) } );
154 }
155 3 $self->{go_result} = $self->_run_subrequest( \%request_params, @_ );
156 3 $self->abort();
157 22 }
158  
159 22 ▶method load ($path) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
160 37 my $compc = $self->interp->load( $self->rel_to_abs($path) );
161 22 }
162  
163 22 ▶method log () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
164 1 return $self->current_comp_class->cmeta->log();
165 22 }
166  
167 22 ▶method notes () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=3 SCAR=11.0
168 return $self->{notes}
169 5 ▶ unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 5 5
170 5 my $key = shift;
171 5 ▶ return $self->{notes}->{$key} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 3 2 5
172 2 return $self->{notes}->{$key} = shift;
173 22 }
174  
175 22 ▶method print () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=3 SCAR=11.0
176 44 my $buffer = $self->_current_buffer;
177 44 for (@_) {
178 44 ▶ $$buffer .= $_ if defined;
Branch: 1 branch
BranchTrueFalseTotal
if defined $_ 42 2 44
179 }
180 22 }
181  
182 22 ▶method rel_to_abs ($path) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine rel_to_abs: called CC=2 SCAR=6.9
183 49 ▶ $path = join( "/", $self->current_comp_class->cmeta->dir_path, $path )
Branch: 1 branch
BranchTrueFalseTotal
unless substr($path, 0, 1) eq "/" 16 33 49
184 unless substr( $path, 0, 1 ) eq '/';
185 49 return $path;
186 22 }
187  
188 22 ▶method scomp () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
189 3 my @params = @_;
190 3 ▶ my $buf = $self->capture( sub { $self->comp(@params) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
191 3 return $buf;
192 22 }
193  
194 22 ▶method visit () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine visit: called CC=2 SCAR=6.9
195 3 my $buf;
196 3 my %request_params = ( %{ $self->{orig_request_params} }, out_method => \$buf );
197 3 ▶ if ( ref( $_[0] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "HASH") 1 2 3
198 1 %request_params = ( %request_params, %{ shift(@_) } );
199 }
200 3 my $result = $self->_run_subrequest( \%request_params, @_ );
201 3 $self->print($buf);
202 3 return $result;
203 22 }
204  
205 #
206 # MODIFIABLE METHODS
207 #
208  
209 22 ▶method cleanup_request () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=2 SCAR=7.0
210 186 $self->interp->_flush_load_cache();
211 186 foreach my $cleanup ( @{ $self->{cleanups} } ) {
212 1 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
213 1 $cleanup->($self);
214 }
215 0 ▶ catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
216 0 warn "error during request cleanup: $_";
217 1 };
218 }
219 22 }
220  
221 22 ▶method construct_page_component ($compc, $args) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine construct_page_component: called CC=1 SCAR=0.0
222 140 return $compc->new( %$args, 'm' => $self );
223 22 }
224  
225 22 ▶method catch_abort ($code) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine catch_abort: called CC=1 SCAR=0.0
226 160 my $retval;
227 160 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
228 160 $retval = $code->();
229 }
230 31 ▶ catch {
Subroutine __ANON__: called CC=2 SCAR=6.9
231 31 my $err = $_;
232 31 ▶ if ( $self->aborted($err) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->aborted($err)) { } 24 7 31
233 24 $retval = $err->aborted_value;
234 }
235 else {
236 7 die $err;
237 }
238 160 };
239 153 return $retval;
240 22 }
241  
242 22 ▶method match_request_path ($request_path) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine match_request_path: called CC=1 SCAR=0.0
243 207 $self->interp->match_request_path->( $self, $request_path );
244 22 }
245  
246 22 ▶method process_output ($outref) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine process_output: called CC=1 SCAR=0.0
247  
248 # No-op by default
249 22 }
250  
251 22 ▶method run () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=6 SCAR=18.0
252  
253 # Get path and either hash or hashref of arguments
254 #
255 186 my $request_path = shift;
256 186 $self->interp->_assert_absolute_path($request_path);
257 186 my $request_args;
258 186 ▶ if ( @_ == 1 && reftype( $_[0] ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and builtin::reftype($_[0]) eq 'HASH') { } 0 186 186
Condition33%1/3
@_ == 1 and builtin::reftype($_[0]) eq "HASH"
!ll&&!rl&&r
18600
MC/DC0%0/2
@_ == 1 and builtin::reftype($_[0]) eq "HASH"
@_ == 1 builtin::reftype($_[0]) eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= builtin::reftype($_[0]) eq "HASH"
ABresult
0X0
100
111
259 0 $request_args = shift;
260 }
261 else {
262 186 $request_args = {@_};
263 }
264  
265 # Save off the requested path and args
266 #
267 186 $self->{request_path} = $request_path;
268 186 $self->{request_args} = $request_args;
269  
270 # Localize current_request and current_buffer until end of scope. Use a guard
271 # because 'local' doesn't work with the aliases inside components.
272 #
273 186 my $save_current_request = $current_request;
274 186 my $save_current_buffer = $current_buffer;
275 186 ▶ scope_guard { $current_request = $save_current_request; $current_buffer = $save_current_buffer };
Subroutine __ANON__: called CC=1 SCAR=0.0
276 186 $current_request = $self;
277 186 $self->_push_buffer();
278  
279 # Clean up after request
280 #
281 186 ▶ scope_guard { $self->cleanup_request() };
Subroutine __ANON__: called CC=1 SCAR=0.0
282  
283 # Flush interp load cache
284 #
285 186 $self->interp->_flush_load_cache();
286  
287 # Check the static_source touch file, if it exists, before the
288 # first component is loaded.
289 #
290 186 $self->interp->_check_static_source_touch_file();
291  
292 # Turn request path into a page component
293 #
294 207 match_request_path:
295 my $page_path = $self->match_request_path($request_path);
296 160 my $page_compc = $self->interp->load($page_path);
297 160 ▶ $log->debugf( "starting request with component '%s'", $page_path )
Branch: 1 branch
BranchTrueFalseTotal
if $Mason::Request::log->is_debug 0 160 160
298 if $log->is_debug;
299  
300 $self->catch_abort(
301 160 ▶ sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
302  
303 # Construct page component
304 #
305 160 my $page = $self->construct_page_component( $page_compc, $request_args );
306 159 $self->{page} = $page;
307  
308 # Dispatch to page component, with 'print' tied to component output.
309 #
310 159 ▶ $self->with_tied_print( sub { $page->handle } );
Subroutine __ANON__: called CC=1 SCAR=0.0
311 }
312 160 );
313  
314 # If declined, retry match
315 #
316 153 ▶ if ( $self->declined ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->declined) 21 132 153
317 21 $self->declined(0);
318 21 $self->{declined_paths}->{$page_path} = 1;
319 21 goto match_request_path;
320 }
321  
322 # If go() was called in this request, return the result of the subrequest
323 #
324 132 ▶ return $self->go_result if defined( $self->go_result );
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->go_result 3 129 132
325  
326 # Send output to its final destination
327 #
328 129 $self->flush_buffer;
329  
330 129 return $self->result;
331 22 }
332  
333 22 ▶method with_tied_print ($code) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine with_tied_print: called CC=1 SCAR=0.0
334 159 local *TH;
335 159 tie *TH, 'Mason::TieHandle';
336 159 my $old = select TH;
337 159 ▶ scope_guard { select $old };
Subroutine __ANON__: called CC=1 SCAR=0.0
338 159 return $code->();
339 22 }
340  
341 #
342 # PRIVATE METHODS
343 #
344  
345 22 ▶method _apply_one_filter ($filter, $yield) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _apply_one_filter: called CC=7 SCAR=20.8
346 42 my $filtered_output;
347 42 ▶ if ( ref($yield) ne 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $yield ne "CODE") 0 42 42
348 0 ▶ my $orig_yield = defined($yield) ? $yield : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $yield ? : 0 0 0
349 0 ▶ $yield = sub { $orig_yield };
Subroutine __ANON__: not called CC=1 SCAR=6.9
350 }
351 42 ▶ if ( ref($filter) eq 'CODE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $filter eq 'CODE') { } 32 10 42
elsif (builtin::blessed($filter) and $filter->can('apply_filter')) { } 9 1 10
352 32 local $_ = $yield->();
353 32 ▶ $_ = '' if !defined($_);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 32 32
354 32 $filtered_output = $filter->($_);
355 }
356 ▶ elsif ( blessed($filter) && $filter->can('apply_filter') ) {
Condition66%2/3
builtin::blessed($filter) and $filter->can("apply_filter")
!ll&&!rl&&r
109
MC/DC50%1/2
builtin::blessed($filter) and $filter->can("apply_filter")
builtin::blessed($filter) $filter->can("apply_filter")
Truth table66%2/3
A and B
A= builtin::blessed($filter)B= $filter->can("apply_filter")
ABresult
0X0
100
111
357 9 $filtered_output = $filter->apply_filter($yield);
358 }
359 else {
360 1 die "'$filter' is neither a code ref nor a filter object";
361 }
362 41 return $filtered_output;
363 22 }
364  
365 22 ▶method _apply_filters () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _apply_filters: called CC=4 SCAR=13.9
366 78 my $yield = pop(@_);
367 78 ▶ if ( ref($yield) ne 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $yield ne "CODE") 1 77 78
368 1 ▶ my $orig_yield = defined($yield) ? $yield : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $yield ? : 1 0 1
369 1 ▶ $yield = sub { $orig_yield };
Subroutine __ANON__: called CC=1 SCAR=0.0
370 }
371 78 ▶ if ( !@_ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not @_) { } 36 42 78
372 36 return $yield->();
373 }
374 else {
375 42 my $filter = pop(@_);
376 42 ▶ return $self->_apply_filters( @_, sub { $self->_apply_one_filter( $filter, $yield ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
377 }
378 22 }
379  
380 22 ▶method _apply_filters_to_output () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _apply_filters_to_output: called CC=1 SCAR=0.0
381 22 my $output_method = pop(@_);
382 27 ▶ my $yield = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
383 27 my @args = @_;
384 27 ▶ $self->capture( sub { $output_method->(@args) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
385 22 };
386 22 my $filtered_output = $self->_apply_filters( @_, $yield );
387 21 $self->print($filtered_output);
388 22 }
389  
390 22 ▶method _comp_not_found ($path) {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _comp_not_found: called CC=1 SCAR=0.0
391 croak sprintf( "could not find component for path '%s' - component root is [%s]",
392 3 $path, join( ", ", @{ $self->interp->comp_root } ) );
393 22 }
394  
395 22 ▶method _current_buffer () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
396 116 $self->{buffer_stack}->[-1];
397 22 }
398  
399 22 ▶method _pop_buffer () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _pop_buffer: called CC=1 SCAR=0.0
400 36 pop( @{ $self->{buffer_stack} } );
401 36 $current_buffer = $self->_current_buffer;
402 22 }
403  
404 22 ▶method _push_buffer () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _push_buffer: called CC=1 SCAR=0.0
405 222 my $s = '';
406 222 push( @{ $self->{buffer_stack} }, \$s );
407 222 $current_buffer = \$s;
408 22 }
409  
410 22 ▶method _request_buffer () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _request_buffer: called CC=1 SCAR=0.0
411 131 $self->{buffer_stack}->[0];
412 22 }
413  
414 22 ▶method _reset_next_id () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine _reset_next_id: called CC=1 SCAR=0.0
415  
416 # for testing
417 6 $next_id = 0;
418 22 }
419  
420 22 ▶method _run_subrequest () {
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
421 6 my $request_params = shift(@_);
422 6 my $path = $self->rel_to_abs( shift(@_) );
423 6 $self->interp->run( $request_params, $path, @_ );
424 22 }
425  
426 22 __PACKAGE__->meta->make_immutable();
427  
428 22 1;
429  
430 __END__
« blib/lib/Mason.pm ↑ Summary blib/lib/Mason/Plugin/LvalueAttributes/Interp.pm »