| 1 | package Reply::Plugin::ResultCache; | ||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:DOY'; | |||||||||||||
| 3 | 1 | $Reply::Plugin::ResultCache::VERSION = '0.42'; | |||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | # ABSTRACT: retain previous results to be able to refer to them later | ||||||||||||||
| 7 | |||||||||||||||
| 8 | 1 | ▶ | use base 'Reply::Plugin'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | |||||||||||||||
| 10 | |||||||||||||||
| 11 | 0 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||
| 12 | 0 | my $class = shift; | |||||||||||||
| 13 | 0 | my %opts = @_; | |||||||||||||
| 14 | |||||||||||||||
| 15 | 0 | my $self = $class->SUPER::new(@_); | |||||||||||||
| 16 | 0 | $self->{results} = []; | |||||||||||||
| 17 | 0 | ▶ | $self->{result_name} = $opts{variable} || 'res'; | ||||||||||||
|
Condition0%0/2
$opts{'variable'} || 'res'
MC/DC0%0/1
$opts{'variable'} || 'res'
$opts{'variable'}
Truth table0%0/2
A
A= $opts{'variable'}
| |||||||||||||||
| 18 | |||||||||||||||
| 19 | 0 | return $self; | |||||||||||||
| 20 | } | ||||||||||||||
| 21 | |||||||||||||||
| 22 | 0 | ▶ | sub execute { | ||||||||||||
|
Subroutine
execute: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||
| 23 | 0 | my $self = shift; | |||||||||||||
| 24 | 0 | my ($next, @args) = @_; | |||||||||||||
| 25 | |||||||||||||||
| 26 | 0 | my @res = $next->(@args); | |||||||||||||
| 27 | 0 | ▶ | if (@res == 1) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 28 | 0 | push @{ $self->{results} }, $res[0]; | |||||||||||||
| 29 | } | ||||||||||||||
| 30 | elsif (@res > 1) { | ||||||||||||||
| 31 | 0 | push @{ $self->{results} }, \@res; | |||||||||||||
| 32 | } | ||||||||||||||
| 33 | |||||||||||||||
| 34 | 0 | return @res; | |||||||||||||
| 35 | } | ||||||||||||||
| 36 | |||||||||||||||
| 37 | 0 | ▶ | sub mangle_result { | ||||||||||||
|
Subroutine
mangle_result: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 38 | 0 | my $self = shift; | |||||||||||||
| 39 | 0 | my ($result) = @_; | |||||||||||||
| 40 | |||||||||||||||
| 41 | 0 | ▶ | return unless defined $result; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 42 | 0 | return '$' . $self->{result_name} . '[' . $#{ $self->{results} } . '] = ' | |||||||||||||
| 43 | . $result; | ||||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 0 | ▶ | sub lexical_environment { | ||||||||||||
|
Subroutine
lexical_environment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 47 | 0 | my $self = shift; | |||||||||||||
| 48 | 0 | return { "\@$self->{result_name}" => [ @{ $self->{results} } ] }; | |||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | 1 | 1; | |||||||||||||
| 52 | |||||||||||||||
| 53 | __END__ | ||||||||||||||