line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Focus::LensMaker; |
2
|
21
|
|
|
907
|
|
1319
|
use strict; |
|
21
|
|
|
|
|
27
|
|
|
21
|
|
|
|
|
544
|
|
3
|
21
|
|
|
21
|
|
70
|
use warnings; |
|
21
|
|
|
|
|
26
|
|
|
21
|
|
|
|
|
410
|
|
4
|
21
|
|
|
21
|
|
69
|
use Exporter qw(import); |
|
21
|
|
|
|
|
21
|
|
|
21
|
|
|
|
|
451
|
|
5
|
21
|
|
|
21
|
|
65
|
use Carp; |
|
21
|
|
|
|
|
26
|
|
|
21
|
|
|
|
|
1916
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(make_lens_from_accessors); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub make_lens_from_accessors { |
10
|
22
|
|
|
22
|
1
|
379
|
my ($getter, $setter) = @_; |
11
|
22
|
|
|
|
|
40
|
my $calling_package = caller; |
12
|
22
|
50
|
|
|
|
78
|
confess "Top level call. Something is wrong." if !defined($calling_package); |
13
|
|
|
|
|
|
|
{ |
14
|
21
|
|
|
21
|
|
85
|
no strict "refs"; |
|
21
|
|
|
|
|
27
|
|
|
21
|
|
|
|
|
2920
|
|
|
22
|
|
|
|
|
23
|
|
15
|
22
|
|
|
|
|
38
|
*{"${calling_package}::apply_lens"} = _create_apply_lens_from_accessors($getter, $setter); |
|
22
|
|
|
|
|
137
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _create_apply_lens_from_accessors { |
20
|
22
|
|
|
22
|
|
30
|
my ($getter, $setter) = @_; |
21
|
|
|
|
|
|
|
return sub { |
22
|
18772
|
|
|
18772
|
|
18711
|
my ($self, $applicative_class, $part_mapper, $whole) = @_; |
23
|
|
|
|
|
|
|
return $applicative_class->build(sub { |
24
|
17353
|
|
|
17353
|
|
27486
|
my $ret = $self->$setter($whole, @_); |
25
|
17347
|
|
|
|
|
33249
|
return $ret; |
26
|
18772
|
|
|
|
|
50759
|
}, map { $part_mapper->($_) } $self->$getter($whole)); |
|
29565
|
|
|
|
|
41159
|
|
27
|
22
|
|
|
|
|
97
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
__END__ |