line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
84
|
use strict; |
|
26
|
|
|
|
|
28
|
|
|
26
|
|
|
|
|
601
|
|
2
|
26
|
|
|
26
|
|
78
|
use warnings; |
|
26
|
|
|
|
|
23
|
|
|
26
|
|
|
|
|
688
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Template::Pure::DataProxy; |
5
|
|
|
|
|
|
|
|
6
|
26
|
|
|
26
|
|
95
|
use Scalar::Util; |
|
26
|
|
|
|
|
25
|
|
|
26
|
|
|
|
|
728
|
|
7
|
26
|
|
|
26
|
|
77
|
use Data::Dumper; |
|
26
|
|
|
|
|
21
|
|
|
26
|
|
|
|
|
7422
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
75
|
|
|
75
|
0
|
162
|
my ($proto, $data, %extra) = @_; |
11
|
75
|
|
33
|
|
|
577
|
my $class = ref($proto) || $proto; |
12
|
75
|
|
|
|
|
251
|
bless +{ |
13
|
|
|
|
|
|
|
data => $data, |
14
|
|
|
|
|
|
|
extra => \%extra, |
15
|
|
|
|
|
|
|
}, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub can { |
19
|
247
|
|
|
247
|
0
|
221
|
my ($self, $target) = @_; |
20
|
247
|
100
|
|
|
|
409
|
if(Scalar::Util::blessed $self->{data}) { |
21
|
53
|
100
|
|
|
|
115
|
if($self->{data}->can($target)) { |
|
|
50
|
|
|
|
|
|
22
|
45
|
|
|
|
|
72
|
return 1; |
23
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$target}) { |
24
|
8
|
|
|
|
|
12
|
return 1; |
25
|
|
|
|
|
|
|
} else { |
26
|
0
|
|
|
|
|
0
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} else { |
29
|
194
|
100
|
|
|
|
319
|
if(exists $self->{data}{$target}) { |
|
|
100
|
|
|
|
|
|
30
|
154
|
|
|
|
|
305
|
return 1; |
31
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$target}) { |
32
|
26
|
|
|
|
|
54
|
return 1; |
33
|
|
|
|
|
|
|
} else { |
34
|
14
|
|
|
|
|
55
|
return 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub AUTOLOAD { |
40
|
188
|
50
|
|
188
|
|
389
|
return if our $AUTOLOAD =~ /DESTROY/; |
41
|
188
|
|
|
|
|
149
|
my $self = shift; |
42
|
188
|
|
|
|
|
657
|
( my $method = $AUTOLOAD ) =~ s{.*::}{}; |
43
|
|
|
|
|
|
|
|
44
|
188
|
100
|
|
|
|
410
|
if(Scalar::Util::blessed $self->{data}) { |
45
|
|
|
|
|
|
|
#warn "Proxy inside Proxy..." if $self->{data}->isa(ref $self); |
46
|
48
|
100
|
|
|
|
71
|
if($self->{data}->can($method)) { |
|
|
50
|
|
|
|
|
|
47
|
44
|
|
|
|
|
124
|
return $self->{data}->$method; |
48
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$method}) { |
49
|
4
|
|
|
|
|
10
|
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
|
140
|
100
|
|
|
|
229
|
if(exists $self->{data}{$method}) { |
|
|
50
|
|
|
|
|
|
57
|
119
|
|
|
|
|
271
|
return $self->{data}{$method}; |
58
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$method}) { |
59
|
21
|
|
|
|
|
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
|
|
|
|
|
|
|
|