line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Focus::Lens::Dynamic; |
2
|
6
|
|
|
6
|
|
1920
|
use strict; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
174
|
|
3
|
6
|
|
|
6
|
|
22
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
142
|
|
4
|
6
|
|
|
6
|
|
18
|
use parent qw(Data::Focus::Lens); |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
31
|
|
5
|
6
|
|
|
6
|
|
290
|
use Scalar::Util qw(blessed); |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
781
|
|
6
|
6
|
|
|
6
|
|
31
|
use Carp; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1294
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub new { |
9
|
64
|
|
|
64
|
1
|
120
|
my ($class, $param) = @_; |
10
|
64
|
|
|
|
|
205
|
return bless \$param, $class; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub _associated_lens { |
14
|
67
|
|
|
67
|
|
51
|
my ($self, $target) = @_; |
15
|
67
|
100
|
100
|
|
|
215
|
if(blessed($target) && $target->can("Lens")) { |
16
|
7
|
|
|
|
|
16
|
my $assoc_lens = $target->Lens($$self); |
17
|
6
|
100
|
|
|
|
10
|
if(! eval { $assoc_lens->isa("Data::Focus::Lens") }) { |
|
6
|
|
|
|
|
29
|
|
18
|
1
|
|
|
|
|
156
|
croak "Lens method did not return a Data::Focus::Lens"; |
19
|
|
|
|
|
|
|
} |
20
|
5
|
|
|
|
|
7
|
return $assoc_lens; |
21
|
|
|
|
|
|
|
} |
22
|
60
|
|
|
|
|
63
|
my $ref = ref($target); |
23
|
60
|
100
|
100
|
|
|
245
|
if(!defined($target) || $ref eq "HASH" || $ref eq "ARRAY") { |
|
|
|
100
|
|
|
|
|
24
|
56
|
|
|
|
|
801
|
require Data::Focus::Lens::HashArray::Index; |
25
|
56
|
|
|
|
|
356
|
return Data::Focus::Lens::HashArray::Index->new(index => $$self); |
26
|
|
|
|
|
|
|
} |
27
|
4
|
|
|
|
|
4
|
return undef; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub apply_lens { |
31
|
67
|
|
|
67
|
1
|
67
|
my ($self, $applicative_class, $part_mapper, $target) = @_; |
32
|
67
|
|
|
|
|
80
|
my $assoc_lens = $self->_associated_lens($target); |
33
|
65
|
100
|
|
|
|
82
|
if(defined($assoc_lens)) { |
34
|
61
|
|
|
|
|
144
|
return $assoc_lens->apply_lens($applicative_class, $part_mapper, $target); |
35
|
|
|
|
|
|
|
}else { |
36
|
4
|
|
|
|
|
6
|
return $applicative_class->pure($target); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |