| 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
| |||||||||||
| 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__ | ||||||||||