line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Focus::LensMaker; |
2
|
15
|
|
|
15
|
|
922
|
use strict; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
488
|
|
3
|
15
|
|
|
15
|
|
59
|
use warnings; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
396
|
|
4
|
15
|
|
|
15
|
|
58
|
use Exporter qw(import); |
|
15
|
|
|
|
|
37
|
|
|
15
|
|
|
|
|
408
|
|
5
|
15
|
|
|
15
|
|
58
|
use Carp; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
1657
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(make_lens_from_accessors); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub make_lens_from_accessors { |
10
|
15
|
|
|
15
|
1
|
242
|
my ($getter, $setter) = @_; |
11
|
15
|
|
|
|
|
34
|
my $calling_package = caller; |
12
|
15
|
50
|
|
|
|
58
|
confess "Top level call. Something is wrong." if !defined($calling_package); |
13
|
|
|
|
|
|
|
{ |
14
|
15
|
|
|
15
|
|
73
|
no strict "refs"; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
2958
|
|
|
15
|
|
|
|
|
54
|
|
15
|
15
|
|
|
|
|
37
|
*{"${calling_package}::apply_lens"} = _create_apply_lens_from_accessors($getter, $setter); |
|
15
|
|
|
|
|
122
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _create_apply_lens_from_accessors { |
20
|
15
|
|
|
15
|
|
23
|
my ($getter, $setter) = @_; |
21
|
|
|
|
|
|
|
return sub { |
22
|
9060
|
|
|
9060
|
|
9329
|
my ($self, $applicative_class, $part_mapper, $whole) = @_; |
23
|
9060
|
|
|
|
|
16316
|
my @parts = $self->$getter($whole); |
24
|
|
|
|
|
|
|
return $applicative_class->build(sub { |
25
|
8337
|
|
|
8337
|
|
15480
|
my $ret = $self->$setter($whole, @_); |
26
|
8331
|
|
|
|
|
20519
|
return $ret; |
27
|
9060
|
|
|
|
|
26148
|
}, map { $part_mapper->($_) } @parts); |
|
14609
|
|
|
|
|
24982
|
|
28
|
15
|
|
|
|
|
80
|
}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
__END__ |