Focus/LensMaker.pm

filter: Statementstmt 100% 30 / 30 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 1 / 1 totaltotal 97.6% 41 / 42 CC 2 SCAR 1.8
CC
2
Cov
97%
make_lens_from_accessors
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Focus/Lens.pm ↑ Summary Focus/Applicative.pm »
1 package Data::Focus::LensMaker;
2 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 21 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
5 21 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 21 our @EXPORT_OK = qw(make_lens_from_accessors);
8  
9 22 ▶sub make_lens_from_accessors {
Subroutine make_lens_from_accessors: called CC=2 SCAR=6.9
Pod documented
10 22 my ($getter, $setter) = @_;
11 22 my $calling_package = caller;
12 22 ▶ confess "Top level call. Something is wrong." if !defined($calling_package);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $calling_package 0 22 22
13 {
14 21 ▶ no strict "refs";
Subroutine BEGIN: called CC=1 SCAR=0.0
15 22 *{"${calling_package}::apply_lens"} = _create_apply_lens_from_accessors($getter, $setter);
16 }
17 }
18  
19 22 ▶sub _create_apply_lens_from_accessors {
Subroutine _create_apply_lens_from_accessors: called CC=1 SCAR=0.0
20 22 my ($getter, $setter) = @_;
21 18772 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
22 18772 my ($self, $applicative_class, $part_mapper, $whole) = @_;
23 17353 ▶ return $applicative_class->build(sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
24 17353 my $ret = $self->$setter($whole, @_);
25 17347 return $ret;
26 18772 }, map { $part_mapper->($_) } $self->$getter($whole));
27 22 };
28 }
29  
30  
31 21 1;
32 __END__
« Focus/Lens.pm ↑ Summary Focus/Applicative.pm »