line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Focus::LensMaker; |
2
|
15
|
|
|
15
|
|
607
|
use strict; |
|
15
|
|
|
|
|
17
|
|
|
15
|
|
|
|
|
438
|
|
3
|
15
|
|
|
15
|
|
62
|
use warnings; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
315
|
|
4
|
15
|
|
|
15
|
|
52
|
use Exporter qw(import); |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
345
|
|
5
|
15
|
|
|
15
|
|
55
|
use Carp; |
|
15
|
|
|
|
|
16
|
|
|
15
|
|
|
|
|
1511
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(make_lens_from_accessors); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub make_lens_from_accessors { |
10
|
15
|
|
|
15
|
1
|
393
|
my ($getter, $setter) = @_; |
11
|
15
|
|
|
|
|
35
|
my $calling_package = caller; |
12
|
15
|
50
|
|
|
|
56
|
confess "Top level call. Something is wrong." if !defined($calling_package); |
13
|
|
|
|
|
|
|
{ |
14
|
15
|
|
|
15
|
|
62
|
no strict "refs"; |
|
15
|
|
|
|
|
29
|
|
|
15
|
|
|
|
|
2367
|
|
|
15
|
|
|
|
|
21
|
|
15
|
15
|
|
|
|
|
30
|
*{"${calling_package}::apply_lens"} = _create_apply_lens_from_accessors($getter, $setter); |
|
15
|
|
|
|
|
111
|
|
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _create_apply_lens_from_accessors { |
20
|
15
|
|
|
15
|
|
24
|
my ($getter, $setter) = @_; |
21
|
|
|
|
|
|
|
return sub { |
22
|
9060
|
|
|
9060
|
|
11302
|
my ($self, $applicative_class, $part_mapper, $whole) = @_; |
|
|
|
|
138
|
|
|
|
23
|
|
|
|
|
|
|
return $applicative_class->build(sub { |
24
|
8337
|
|
|
8337
|
|
16216
|
my $ret = $self->$setter($whole, @_); |
25
|
8331
|
|
|
|
|
21088
|
return $ret; |
26
|
9060
|
|
|
|
|
30687
|
}, map { $part_mapper->($_) } $self->$getter($whole)); |
|
14609
|
|
|
|
|
25592
|
|
27
|
15
|
|
|
|
|
75
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
1; |
32
|
|
|
|
|
|
|
__END__ |