line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
26
|
|
|
26
|
|
86
|
use strict; |
|
26
|
|
|
|
|
29
|
|
|
26
|
|
|
|
|
583
|
|
2
|
26
|
|
|
26
|
|
73
|
use warnings; |
|
26
|
|
|
|
|
27
|
|
|
26
|
|
|
|
|
717
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Template::Pure::DataProxy; |
5
|
|
|
|
|
|
|
|
6
|
26
|
|
|
26
|
|
88
|
use Scalar::Util; |
|
26
|
|
|
|
|
26
|
|
|
26
|
|
|
|
|
874
|
|
7
|
26
|
|
|
26
|
|
87
|
use Data::Dumper; |
|
26
|
|
|
|
|
31
|
|
|
26
|
|
|
|
|
7508
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
75
|
|
|
75
|
0
|
162
|
my ($proto, $data, %extra) = @_; |
11
|
75
|
|
33
|
|
|
275
|
my $class = ref($proto) || $proto; |
12
|
75
|
|
|
|
|
256
|
bless +{ |
13
|
|
|
|
|
|
|
data => $data, |
14
|
|
|
|
|
|
|
extra => \%extra, |
15
|
|
|
|
|
|
|
}, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub can { |
19
|
245
|
|
|
245
|
0
|
225
|
my ($self, $target) = @_; |
20
|
245
|
100
|
|
|
|
430
|
if(Scalar::Util::blessed $self->{data}) { |
21
|
53
|
100
|
|
|
|
116
|
if($self->{data}->can($target)) { |
|
|
50
|
|
|
|
|
|
22
|
45
|
|
|
|
|
76
|
return 1; |
23
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$target}) { |
24
|
8
|
|
|
|
|
16
|
return 1; |
25
|
|
|
|
|
|
|
} else { |
26
|
0
|
|
|
|
|
0
|
return 0; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} else { |
29
|
192
|
100
|
|
|
|
328
|
if(exists $self->{data}{$target}) { |
|
|
100
|
|
|
|
|
|
30
|
154
|
|
|
|
|
325
|
return 1; |
31
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$target}) { |
32
|
24
|
|
|
|
|
47
|
return 1; |
33
|
|
|
|
|
|
|
} else { |
34
|
14
|
|
|
|
|
42
|
return 0; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub AUTOLOAD { |
40
|
186
|
50
|
|
186
|
|
415
|
return if our $AUTOLOAD =~ /DESTROY/; |
41
|
186
|
|
|
|
|
163
|
my $self = shift; |
42
|
186
|
|
|
|
|
629
|
( my $method = $AUTOLOAD ) =~ s{.*::}{}; |
43
|
|
|
|
|
|
|
|
44
|
186
|
100
|
|
|
|
532
|
if(Scalar::Util::blessed $self->{data}) { |
45
|
|
|
|
|
|
|
#warn "Proxy inside Proxy..." if $self->{data}->isa(ref $self); |
46
|
48
|
100
|
|
|
|
77
|
if($self->{data}->can($method)) { |
|
|
50
|
|
|
|
|
|
47
|
44
|
|
|
|
|
127
|
return $self->{data}->$method; |
48
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$method}) { |
49
|
4
|
|
|
|
|
12
|
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
|
|
|
|
219
|
if(exists $self->{data}{$method}) { |
|
|
50
|
|
|
|
|
|
57
|
119
|
|
|
|
|
290
|
return $self->{data}{$method}; |
58
|
|
|
|
|
|
|
} elsif(exists $self->{extra}{$method}) { |
59
|
19
|
|
|
|
|
40
|
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
|
|
|
|
|
|
|
|