| 1 | package Data::Focus::Lens::Dynamic; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use parent qw(Data::Focus::Lens); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 64 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 64 | my ($class, $param) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 64 | return bless \$param, $class; | |||||||||||||||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 67 | ▶ | sub _associated_lens { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_associated_lens: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 67 | my ($self, $target) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 67 | ▶ | if(blessed($target) && $target->can("Lens")) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
builtin::blessed($target) and $target->can("Lens")
MC/DC100%2/2
builtin::blessed($target) and $target->can("Lens")
builtin::blessed($target)
$target->can("Lens")
Truth table100%3/3
A and B
A= builtin::blessed($target)B= $target->can("Lens")
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 7 | my $assoc_lens = $target->Lens($$self); | |||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | if(! eval { $assoc_lens->isa("Data::Focus::Lens") }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | croak "Lens method did not return a Data::Focus::Lens"; | |||||||||||||||||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | return $assoc_lens; | |||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 60 | my $ref = ref($target); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 60 | ▶ | if(!defined($target) || $ref eq "HASH" || $ref eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
not defined $target or $ref eq "HASH" or $ref eq "ARRAY"
not defined $target or $ref eq "HASH"
MC/DC100%3/3
not defined $target or $ref eq "HASH" or $ref eq "ARRAY"
not defined $target
$ref eq "HASH"
$ref eq "ARRAY"
Truth table100%4/4
not(A) or B or C
A= not defined $targetB= $ref eq "HASH"C= $ref eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 24 | 56 | require Data::Focus::Lens::HashArray::Index; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 56 | return Data::Focus::Lens::HashArray::Index->new(index => $$self); | |||||||||||||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 67 | ▶ | sub apply_lens { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_lens: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 67 | my ($self, $applicative_class, $part_mapper, $target) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 67 | my $assoc_lens = $self->_associated_lens($target); | |||||||||||||||||||||||||||||||||||||||||
| 33 | 65 | ▶ | if(defined($assoc_lens)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 61 | return $assoc_lens->apply_lens($applicative_class, $part_mapper, $target); | |||||||||||||||||||||||||||||||||||||||||
| 35 | }else { | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 4 | return $applicative_class->pure($target); | |||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 42 | __END__ | ||||||||||||||||||||||||||||||||||||||||||