| 1 | package Catmandu::Fix::Inlineable; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 115 | ▶ | use Catmandu::Sane; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 115 | our $VERSION = '1.2025'; | |||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 115 | ▶ | use Clone qw(clone); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 115 | ▶ | use Moo::Role; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 115 | ▶ | use namespace::clean; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 115 | requires 'fix'; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 99 | ▶ | sub import { | ||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.4
| |||||||||||||||||||||
| 14 | 99 | my $target = caller; | |||||||||||||||||||
| 15 | 99 | my ($pkg, %opts) = @_; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 99 | ▶ | if (my $sym = $opts{as}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 18 | 2 | ▶ | $opts{cache} //= 1; | ||||||||||||||||||
|
Condition50%1/2
$opts{"cache"} //= 1
MC/DC0%0/1
$opts{"cache"} //= 1
$opts{"cache"}
Truth table50%1/2
A
A= $opts{"cache"}
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 2 | ▶ | my $sub = sub { | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=18.0
| |||||||||||||||||||||
| 21 | 2 | my $data = shift; | |||||||||||||||||||
| 22 | 2 | my $fixer; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 2 | state $cache = {}; | |||||||||||||||||||
| 25 | 2 | ▶ | if ($opts{cache}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 26 | 2 | my $key = join('--', @_); | |||||||||||||||||||
| 27 | 2 | ▶ | $fixer = $cache->{$key} ||= $pkg->new(@_); | ||||||||||||||||||
|
Condition33%1/3
$cache->{$key} ||= $pkg->new(@_)
MC/DC0%0/2
$cache->{$key} ||= $pkg->new(@_)
$cache->{$key}
$pkg->new(@_)
Truth table33%1/3
A ||= B
A= $cache->{$key}B= $pkg->new(@_)
| |||||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | 2 | ▶ | $fixer ||= $pkg->new(@_); | ||||||||||||||||||
|
Condition33%1/3
$fixer ||= $pkg->new(@_)
MC/DC0%0/2
$fixer ||= $pkg->new(@_)
$fixer
$pkg->new(@_)
Truth table33%1/3
A ||= B
A= $fixerB= $pkg->new(@_)
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 2 | ▶ | if ($opts{clone}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 33 | 0 | $data = clone($data); | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 2 | $fixer->fix($data); | |||||||||||||||||||
| 37 | 2 | }; | |||||||||||||||||||
| 38 | 115 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 39 | 2 | *{"${target}::$sym"} = $sub; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 115 | 1; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | __END__ | ||||||||||||||||||||