line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mason::Plugin::Defer::Request; |
2
|
|
|
|
|
|
|
$Mason::Plugin::Defer::Request::VERSION = '2.23'; |
3
|
20
|
|
|
20
|
|
12526
|
use Mason::PluginRole; |
|
20
|
|
|
|
|
39
|
|
|
20
|
|
|
|
|
169
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
has 'defers' => ( is => 'rw', init_arg => undef, default => sub { [] } ); |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
before 'flush_buffer' => sub { |
8
|
|
|
|
|
|
|
my $self = shift; |
9
|
|
|
|
|
|
|
$self->_apply_defers_to_request_buffer(); |
10
|
|
|
|
|
|
|
}; |
11
|
|
|
|
|
|
|
|
12
|
20
|
|
|
20
|
|
135140
|
method defer ($code) { |
|
2
|
|
|
2
|
|
5
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
3
|
|
13
|
2
|
|
|
|
|
78
|
my $marker = $self->interp->_construct_distinct_string(); |
14
|
2
|
|
|
|
|
4
|
push( @{ $self->{defers} }, { marker => $marker, code => $code } ); |
|
2
|
|
|
|
|
13
|
|
15
|
2
|
|
|
|
|
11
|
return $marker; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
20
|
|
|
20
|
|
7882
|
method _apply_defers_to_request_buffer () { |
|
127
|
|
|
127
|
|
218
|
|
|
127
|
|
|
|
|
209
|
|
19
|
127
|
100
|
|
|
|
190
|
if ( my @defers = @{ $self->{defers} } ) { |
|
127
|
|
|
|
|
787
|
|
20
|
1
|
|
|
|
|
1
|
my $request_buffer = ${ $self->_request_buffer }; |
|
1
|
|
|
|
|
12
|
|
21
|
1
|
|
|
|
|
3
|
foreach my $defer (@defers) { |
22
|
2
|
|
|
|
|
11
|
my $subst = $defer->{marker}; |
23
|
2
|
|
|
|
|
8
|
my $repl = $defer->{code}->(); |
24
|
2
|
|
|
|
|
58
|
$request_buffer =~ s/\Q$subst\E/$repl/; |
25
|
|
|
|
|
|
|
} |
26
|
1
|
|
|
|
|
4
|
${ $self->_request_buffer } = $request_buffer; |
|
1
|
|
|
|
|
42
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
1; |