line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
86
|
use strict; |
|
26
|
|
|
|
|
26
|
|
|
26
|
|
|
|
|
578
|
|
2
|
26
|
|
|
26
|
|
73
|
use warnings; |
|
26
|
|
|
|
|
26
|
|
|
26
|
|
|
|
|
662
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Template::Pure::DataProxy; |
5
|
|
|
|
|
|
|
|
6
|
26
|
|
|
26
|
|
90
|
use Scalar::Util; |
|
26
|
|
|
|
|
24
|
|
|
26
|
|
|
|
|
850
|
|
7
|
26
|
|
|
26
|
|
78
|
use Data::Dumper; |
|
26
|
|
|
|
|
22
|
|
|
26
|
|
|
|
|
7343
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
75
|
|
|
75
|
0
|
150
|
my ($proto, $data, %extra) = @_; |
11
|
75
|
|
33
|
|
|
277
|
my $class = ref($proto) || $proto; |
12
|
75
|
|
|
|
|
253
|
bless +{ |
13
|
|
|
|
|
|
|
data => $data, |
14
|
|
|
|
|
|
|
extra => \%extra, |
15
|
|
|
|
|
|
|
}, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub can { |
19
|
245
|
|
|
245
|
0
|
231
|
my ($self, $target) = @_; |
20
|
245
|
100
|
|
|
|
412
|
if(Scalar::Util::blessed $self->{data}) { |
21
|
53
|
100
|
|
|
|
118
|
if($self->{data}->can($target)) { |
|
|
50
|
|
|
|
|
|
22
|
45
|
|
|
|
|
73
|
return 1; |
23
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$target}) { |
24
|
8
|
|
|
|
|
15
|
return 1; |
25
|
|
|
|
|
|
|
} else { |
26
|
0
|
|
|
|
|
0
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} else { |
29
|
192
|
100
|
|
|
|
331
|
if(exists $self->{data}{$target}) { |
|
|
100
|
|
|
|
|
|
30
|
154
|
|
|
|
|
315
|
return 1; |
31
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$target}) { |
32
|
24
|
|
|
|
|
50
|
return 1; |
33
|
|
|
|
|
|
|
} else { |
34
|
14
|
|
|
|
|
41
|
return 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub AUTOLOAD { |
40
|
186
|
50
|
|
186
|
|
399
|
return if our $AUTOLOAD =~ /DESTROY/; |
41
|
186
|
|
|
|
|
157
|
my $self = shift; |
42
|
186
|
|
|
|
|
627
|
( my $method = $AUTOLOAD ) =~ s{.*::}{}; |
43
|
|
|
|
|
|
|
|
44
|
186
|
100
|
|
|
|
419
|
if(Scalar::Util::blessed $self->{data}) { |
45
|
|
|
|
|
|
|
#warn "Proxy inside Proxy..." if $self->{data}->isa(ref $self); |
46
|
48
|
100
|
|
|
|
80
|
if($self->{data}->can($method)) { |
|
|
50
|
|
|
|
|
|
47
|
44
|
|
|
|
|
130
|
return $self->{data}->$method; |
48
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$method}) { |
49
|
4
|
|
|
|
|
11
|
return $self->{extra}{$method}; |
50
|
|
|
|
|
|
|
} else { |
51
|
0
|
|
|
|
|
0
|
return; |
52
|
|
|
|
|
|
|
#die "No value at $method for $self"; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} else { |
55
|
|
|
|
|
|
|
## I think we can assume its a hashref then. |
56
|
138
|
100
|
|
|
|
208
|
if(exists $self->{data}{$method}) { |
|
|
50
|
|
|
|
|
|
57
|
119
|
|
|
|
|
279
|
return $self->{data}{$method}; |
58
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$method}) { |
59
|
19
|
|
|
|
|
45
|
return $self->{extra}{$method}; |
60
|
|
|
|
|
|
|
} else { |
61
|
0
|
|
|
|
|
|
return; |
62
|
|
|
|
|
|
|
#die "No value at $method in: ".Dumper($self->{data}) ."\n or \n". Dumper($self->{extra}); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|