| 1 | 14 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 14 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | package Template::Pure::DataContext; | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 14 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 14 | ▶ | use Template::Pure::UndefObject; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 14 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | use overload | ||||||||||||||||||||
| 11 | 4 | ▶ | q{""} => sub { shift->value }, | ||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 14 | ▶ | 'fallback' => 1; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | sub new { | ||||||||||||||||||||
| 15 | 116 | ▶ | my ($proto, $data_proto, $root) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||
| 16 | 116 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition66%2/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 17 | 116 | ▶ | return bless +{ | ||||||||||||||||||
|
Condition66%2/3
$root || $data_proto
MC/DC0%0/2
$root || $data_proto
$root
$data_proto
Truth table66%2/3
A || B
A= $rootB= $data_proto
| |||||||||||||||||||||
| 18 | value => $data_proto, | ||||||||||||||||||||
| 19 | root => ($root||$data_proto), | ||||||||||||||||||||
| 20 | }, $class; | ||||||||||||||||||||
| 21 | } | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 95 | ▶ | sub value { shift->{value} } | ||||||||||||||||||
|
Subroutine
value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | sub at { | ||||||||||||||||||||
| 26 | 75 | ▶ | my ($self, %at) = @_; | ||||||||||||||||||
|
Subroutine
at: called CC=11 SCAR=26.5
Pod
undocumented
| |||||||||||||||||||||
| 27 | 75 | ▶ | my $current = $at{absolute} ? $self->{root} : $self->{value}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 28 | 75 | foreach my $at(@{$at{path}}) { | |||||||||||||||||||
| 29 | 117 | ▶ | my $key = $at->{key} || die "missing key"; | ||||||||||||||||||
|
Condition50%1/2
$at->{'key'} || die('missing key')
MC/DC0%0/1
$at->{'key'} || die('missing key')
$at->{'key'}
Truth table50%1/2
A
A= $at->{'key'}
| |||||||||||||||||||||
| 30 | 117 | ▶ | if(blessed $current) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | 17 | ▶ | if($current->can($key)) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 32 | 17 | $current = $current->$key; | |||||||||||||||||||
| 33 | } elsif($at->{optional}) { | ||||||||||||||||||||
| 34 | 0 | $current = undef; | |||||||||||||||||||
| 35 | } else { | ||||||||||||||||||||
| 36 | 0 | die "Missing path '$key'"; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | } elsif(ref $current eq 'HASH') { | ||||||||||||||||||||
| 39 | 100 | ▶ | if(exists $current->{$key}) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 40 | 97 | $current = $current->{$key}; | |||||||||||||||||||
| 41 | } elsif($at->{optional}) { | ||||||||||||||||||||
| 42 | 3 | $current = undef; | |||||||||||||||||||
| 43 | } else { | ||||||||||||||||||||
| 44 | 0 | warn Dumper $at; | |||||||||||||||||||
| 45 | 0 | die "Missing path '$key'"; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | } else { | ||||||||||||||||||||
| 48 | 0 | die "Can't find path '$key' in ". Dumper $current; | |||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | 117 | ▶ | if($at->{maybe}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 1 | $current = Template::Pure::UndefObject->maybe($current); | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | 75 | return $self->new($current, $self->{root}); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 14 | 1; | |||||||||||||||||||
| 58 | |||||||||||||||||||||