| 1 | package YAOO; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 6 | ▶ | use strict; no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use Carp qw/croak/; use Tie::IxHash; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use feature qw/state/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use Blessed::Merge; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our $VERSION = '0.08'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 6 | our (%TYPES, %object, $LAST); | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | sub make_keyword { | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 308 | ▶ | my ($called, $key, $cb) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
make_keyword: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 308 | *{"${called}::$key"} = $cb; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 308 | $LAST = 10000000000000000000; | |||||||||||||||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | sub import { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 9 | ▶ | my ($package, @attributes) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 9 | my $called = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 9 | strict->import(); | |||||||||||||||||||||||||||||||||||||||||
| 23 | 9 | warnings->import(); | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 9 | for my $is (qw/ro rw/) { | |||||||||||||||||||||||||||||||||||||||||
| 26 | 18 | ▶ | make_keyword($called, $is, sub { is => $is }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 9 | for my $key (qw/isa default coerce required trigger lazy delay build_order/) { | |||||||||||||||||||||||||||||||||||||||||
| 30 | make_keyword($called, $key, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 31 | ▶ | my (@value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 31 | ▶ | return $key => scalar @value > 1 ? @value : ($value[0] || 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$value[0] or 1
MC/DC100%1/1
$value[0] or 1
$value[0]
Truth table100%2/2
A
A= $value[0]
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 72 | }); | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 9 | for my $isa ( qw/any string scalarref integer float boolean ordered_hash hash array object fh/ ) { | |||||||||||||||||||||||||||||||||||||||||
| 37 | make_keyword($called, $isa, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 27 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | my @return = ( | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 27 | \&{"${package}::${isa}"}, | |||||||||||||||||||||||||||||||||||||||||
| 41 | type => $isa, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | 27 | build_default => \&{"${package}::build_${isa}"} | |||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 27 | ▶ | push @return, (default => ($isa eq 'ordered_hash' ? sub { deep_clone_ordered_hash(@args) } : sub { deep_clone( scalar @args > 1 ? $isa eq 'hash' ? {@args} : \@args : @args) })) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | if (scalar @args); | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 27 | @return; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 99 | }); | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 9 | ▶ | make_keyword($called, 'auto_build', sub { $object{$called}{auto_build} = 1; }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | make_keyword($called, 'extends', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | my $extend = caller(); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | for my $inherit (@args) { | |||||||||||||||||||||||||||||||||||||||||
| 56 | 3 | load($inherit); | |||||||||||||||||||||||||||||||||||||||||
| 57 | 3 | push @{*{\*{"${extend}::ISA"}}{ARRAY}}, $inherit; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 3 | ▶ | return unless $object{$inherit}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 3 | my $bm = Blessed::Merge->new(blessed => 0, same => 0); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 3 | $object{$extend} = $bm->merge($object{$extend}, $object{$inherit}); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 3 | for my $name (keys %{$object{$extend}{has}}) { | |||||||||||||||||||||||||||||||||||||||||
| 62 | make_keyword($extend, $name, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 12 | ▶ | my ($self, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 12 | ▶ | if ($value && ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$value and $YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
$YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw" or [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
MC/DC33%1/3
$value and $YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
$value
$YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw"
[split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
Truth table50%2/4
A and B or C
A= $valueB= $YAOO::object{$extend}{"has"}{$name}{"is"} eq "rw"C= [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | $object{$extend}{has}{$name}->{is} eq 'rw' | ||||||||||||||||||||||||||||||||||||||||||
| 66 | || [split '::', [caller(1)]->[3]]->[-1] =~ m/^new|build|set_defaults|auto_build$/ | ||||||||||||||||||||||||||||||||||||||||||
| 67 | )) { | ||||||||||||||||||||||||||||||||||||||||||
| 68 | $value = $object{$extend}{has}{$name}->{coerce}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 10 | ▶ | if ($object{$extend}{has}{$name}->{coerce}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | $object{$extend}{has}{$name}->{required}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 71 | 10 | ▶ | if ($object{$extend}{$name}->{required}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 10 | $value = $object{$extend}{has}{$name}->{isa}($value, $name); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 10 | $self->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 74 | $object{$extend}{has}{$name}->{trigger}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 10 | ▶ | if ($object{$extend}{has}{$name}->{trigger}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 12 | $self->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 15 | }); | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 3 | for my $name (keys %{$object{$extend}{method}}) { | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | make_keyword($extend, $name, $object{$called}{method}{$name}); | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | make_keyword($called, 'require_has', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | push @{ $object{$called}{require_has} }, @args; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | make_keyword($called, 'require_sub', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 1 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 1 | push @{ $object{$called}{require_sub} }, @args; | |||||||||||||||||||||||||||||||||||||||||
| 94 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | make_keyword($called, 'require_method', sub { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my (@args) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | push @{ $object{$called}{require_sub} }, @args; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 9 | $object{$called}{has} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 102 | 9 | $object{$called}{method} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | make_keyword($called, "method", sub { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 1 | ▶ | my ($name, $sub) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | $object{$called}{method}{$name} = $sub; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | make_keyword($called, $name, $sub); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 9 | ▶ | make_keyword($called, 'has', sub { build_attribute($called, @_) }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | make_keyword($called, "new", sub { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 9 | ▶ | my ($pkg) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 9 | my $self = bless { }, $pkg; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 9 | require_has($called); | |||||||||||||||||||||||||||||||||||||||||
| 117 | 8 | require_sub($self, $called); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 8 | require_method($called); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 8 | ▶ | auto_ld($self, $called, 'lazy') if ($object{$called}{lazy}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 8 | set_defaults($self, $called); | |||||||||||||||||||||||||||||||||||||||||
| 121 | 8 | ▶ | auto_build($self, $called, @_) if ($object{$called}{auto_build}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 8 | ▶ | $self->build(@_) if ($self->can('build')); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 8 | ▶ | auto_ld($self, $called, 'delay') if ($object{$called}{delay}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | sub build_attribute { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 31 | ▶ | my ($called, $name, @attrs) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_attribute: called CC=20 SCAR=31.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 31 | ▶ | my $ref = ref $name || 'STRING'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
ref $name || 'STRING'
MC/DC100%1/1
ref $name || 'STRING'
ref $name
Truth table100%2/2
A
A= ref $name
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 31 | my $attribute_extend; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 31 | ▶ | if ($name =~ s/^_([a-zA-Z].*)/$1/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $attribute_extend = 1; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 31 | ▶ | if ($ref eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | build_attribute($called, $_, @attrs) for @{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } elsif ($ref eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | build_attribute($called, $_, %{ $name->{$_} }) for keys %{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 31 | ▶ | if ( !$attribute_extend && $object{$called}{has}{$name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $attribute_extend and $YAOO::object{$called}{"has"}{$name}
MC/DC0%0/2
not $attribute_extend and $YAOO::object{$called}{"has"}{$name}
not $attribute_extend
$YAOO::object{$called}{"has"}{$name}
Truth table33%1/3
not(A) and B
A= not $attribute_extendB= $YAOO::object{$called}{"has"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | croak sprintf "%s attribute already defined for %s object.", $name, $called; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 31 | ▶ | if ( scalar @attrs % 2 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | croak sprintf "Invalid attribute definition odd number of key/value pairs (%s) passed with %s in %s object", scalar @attrs, $name, $called; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 31 | $object{$called}{has}{$name} = {@attrs}; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | $object{$called}{has}{$name}{is} = 'rw' | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 31 | ▶ | if (! $object{$called}{has}{$name}{is}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | $object{$called}{has}{$name}{isa} = $TYPES{all} | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 31 | ▶ | if (not defined $object{$called}{has}{$name}{isa}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 31 | ▶ | if ($object{$called}{has}{$name}{default}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 13 | ▶ | if ($object{$called}{has}{$name}{default} =~ m/^1$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $object{$called}{has}{$name}{value} = $object{$called}{has}{$name}{build_default}(); | |||||||||||||||||||||||||||||||||||||||||
| 163 | } elsif (ref $object{$called}{has}{$name}{default} eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 13 | $object{$called}{has}{$name}{value} = $object{$called}{has}{$name}{default}(); | |||||||||||||||||||||||||||||||||||||||||
| 165 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | $object{$called}{has}{$name}{value} = $object{$called}{has}{$name}{type} eq 'ordered_hash' | ||||||||||||||||||||||||||||||||||||||||||
| 167 | ? deep_clone_ordered_hash($object{$called}{has}{$name}{default}) | ||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | : deep_clone($object{$called}{has}{$name}{default}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 31 | ▶ | if ($object{$called}{has}{$name}{required}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $object{$called}{has}{$name}{required} = \&required; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 31 | ▶ | if ($object{$called}{has}{$name}{lazy}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 4 | push @{$object{$called}{lazy}}, $name; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 31 | ▶ | if ($object{$called}{has}{$name}{delay}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | push @{$object{$called}{delay}}, $name; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | make_keyword($called, $name, sub { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 60 | ▶ | my ($self, $value) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 60 | ▶ | if (@_ > 1 && ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
@_ > 1 and $YAOO::object{$called}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
$YAOO::object{$called}{"has"}{$name}{"is"} eq "rw" or [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
MC/DC33%1/3
@_ > 1 and $YAOO::object{$called}{"has"}{$name}{"is"} eq "rw" || [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
@_ > 1
$YAOO::object{$called}{"has"}{$name}{"is"} eq "rw"
[split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
Truth table50%2/4
A and B or C
A= @_ > 1B= $YAOO::object{$called}{"has"}{$name}{"is"} eq "rw"C= [split(/::/, [caller 1]->[3], 0)]->[-1] =~ /^new|build|set_defaults|auto_build$/
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | $object{$called}{has}{$name}->{is} eq 'rw' | ||||||||||||||||||||||||||||||||||||||||||
| 188 | || [split '::', [caller(1)]->[3]]->[-1] =~ m/^new|build|set_defaults|auto_build$/ | ||||||||||||||||||||||||||||||||||||||||||
| 189 | )) { | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 33 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | $value = $object{$called}{has}{$name}->{coerce}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 32 | ▶ | if ($object{$called}{has}{$name}->{coerce}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | $object{$called}{has}{$name}{required}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 32 | ▶ | if ($object{$called}{$name}->{required}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 32 | $value = $object{$called}{has}{$name}{isa}($value, $name); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 32 | $self->{$name} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 197 | $object{$called}{has}{$name}{trigger}($self, $value, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 32 | ▶ | if ($object{$called}{has}{$name}->{trigger}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | $self->{$name} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 60 | $self->{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 31 | ▶ | }) unless $attribute_extend; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | sub require_has { | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 9 | ▶ | my ($called) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_has: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 9 | for (@{ $object{$called}{require_has} }) { | |||||||||||||||||||||||||||||||||||||||||
| 210 | croak sprintf "The required %s attribute is not defined in the %s object.", $_, $called | ||||||||||||||||||||||||||||||||||||||||||
| 211 | 6 | ▶ | if (! $object{$called}{has}{$_} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | sub require_sub { | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 8 | ▶ | my ($self, $called) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_sub: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 8 | for (@{ $object{$called}{require_sub} }) { | |||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | ▶ | croak sprintf "The required %s sub is not defined in the %s object.", $_, $called | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 219 | if (! $self->can($_) ); | ||||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | sub require_method { | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 8 | ▶ | my ($called) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
require_method: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 8 | for (@{ $object{$called}{require_method} }) { | |||||||||||||||||||||||||||||||||||||||||
| 226 | croak sprintf "The required %s method is not defined in the %s object.", $_, $called | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if (! $object{$called}{method}{$_} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | sub set_defaults { | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 8 | ▶ | my ($self, $called) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_defaults: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | defined $object{$called}{has}{$_}{value} && $self->$_($object{$called}{has}{$_}{type} eq 'ordered_hash' | ||||||||||||||||||||||||||||||||||||||||||
| 235 | ? deep_clone_ordered_hash($object{$called}{has}{$_}{value}) | ||||||||||||||||||||||||||||||||||||||||||
| 236 | 46 | ▶ | : deep_clone($object{$called}{has}{$_}{value})) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | 71 | ▶ | } sort { ($object{$called}{has}{$a}{build_order} || $LAST) <=> ($object{$called}{has}{$b}{build_order} || $LAST) } | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$a}{'build_order'}
$YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'}
$YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$a}{'build_order'}B= $YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$b}{'build_order'}B= $YAOO::LAST
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 8 | keys %{$object{$called}{has}}; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | sub auto_build { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 8 | ▶ | my ($self, $called, %build) = (shift, shift, scalar @_ == 1 ? %{ $_[0] } : @_); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_build: called CC=5 SCAR=17.5
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 15 | ▶ | if ($self->can($_)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 15 | $self->$_($build{$_}); | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 8 | ▶ | } sort { ($object{$called}{has}{$a}{build_order} || $LAST) <=> ($object{$called}{has}{$b}{build_order} || $LAST) } | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$a}{'build_order'}
$YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'}
$YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$a}{'build_order'}B= $YAOO::LAST
Truth table66%2/3
A || B
A= $YAOO::object{$called}{'has'}{$b}{'build_order'}B= $YAOO::LAST
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | keys %build; | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | sub auto_ld { | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | ▶ | my ($self, $called, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auto_ld: called CC=5 SCAR=19.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | map { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 5 | ▶ | my $cb_value = ref $object{$called}{has}{$_}{$type} || $object{$called}{has}{$_}{$type} !~ m/^1$/ ? $object{$called}{has}{$_}{$type} : $object{$called}{has}{$_}{build_default}->(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $YAOO::object{$called}{"has"}{$_}{$type} or not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
MC/DC0%0/2
ref $YAOO::object{$called}{"has"}{$_}{$type} or not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
ref $YAOO::object{$called}{"has"}{$_}{$type}
not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
Truth table33%1/3
A or not(B)
A= ref $YAOO::object{$called}{"has"}{$_}{$type}B= not $YAOO::object{$called}{"has"}{$_}{$type} =~ /^1$/
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 5 | $self->$_($cb_value); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } sort { | ||||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | ▶ | ($object{$called}{has}{$a}{build_order} || $LAST) <=> ($object{$called}{has}{$b}{build_order} || $LAST) | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$a}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$a}{'build_order'}
$YAOO::LAST
MC/DC0%0/2
$YAOO::object{$called}{'has'}{$b}{'build_order'} || $YAOO::LAST
$YAOO::object{$called}{'has'}{$b}{'build_order'}
$YAOO::LAST
Truth table33%1/3
A || B
A= $YAOO::object{$called}{'has'}{$a}{'build_order'}B= $YAOO::LAST
Truth table33%1/3
A || B
A= $YAOO::object{$called}{'has'}{$b}{'build_order'}B= $YAOO::LAST
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 2 | } @{ $object{$called}{$type} }; | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | sub required { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my ($self, $value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
required: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | if ( not defined $value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | croak sprintf "No defined value passed to the required %s attribute.", | |||||||||||||||||||||||||||||||||||||||||
| 266 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub any { $_[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | ▶ | sub build_string { "" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | sub string { | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 6 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
string: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 6 | ▶ | if (ref $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | croak sprintf "The value passed to the %s attribute does not match the string type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 278 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | 6 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||
| 283 | 4 | ▶ | sub build_integer { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_integer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | sub integer { | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 12 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
integer: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 12 | ▶ | if (ref $value || $value !~ m/^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $value or not $value =~ /^\d+$/
MC/DC0%0/2
ref $value or not $value =~ /^\d+$/
ref $value
not $value =~ /^\d+$/
Truth table33%1/3
A or not(B)
A= ref $valueB= not $value =~ /^\d+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | croak sprintf "The value passed to the %s attribute does not match the type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 289 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 12 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | sub build_float { 0.00 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_float: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | sub float { | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
float: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if (ref $value || $value !~ m/^\d+\.\d+$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $value or not $value =~ /^\d+\.\d+$/
MC/DC0%0/2
ref $value or not $value =~ /^\d+\.\d+$/
ref $value
not $value =~ /^\d+\.\d+$/
Truth table0%0/3
A or not(B)
A= ref $valueB= not $value =~ /^\d+\.\d+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | croak sprintf "The value passed to the %s attribute does not match the float constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 300 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub build_scalarref { \"" } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_scalarref: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | sub scalarref { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scalarref: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if (ref $value ne 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | croak sprintf "The value passed to the %s attribute does not match the scalarref constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 311 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | sub build_boolean { \1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_boolean: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | sub boolean { | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 2 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
boolean: called CC=3 SCAR=11.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 2 | ▶ | if (! ref $value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 2 | $value = \!!$value; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 2 | ▶ | if (ref $value ne 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | croak sprintf "The value passed to the %s attribute does not match the scalarref constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 325 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 2 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | sub build_ordered_hash { { } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_ordered_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 7 | ▶ | sub ordered_hash { hash(@_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ordered_hash: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | sub build_hash { {} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_hash: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | sub hash { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 15 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hash: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 15 | ▶ | if (ref $value ne 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | croak sprintf "The value passed to the %s attribute does not match the hash type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 340 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 15 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | sub build_array { [] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_array: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | sub array { | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 7 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
array: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 7 | ▶ | if (ref $value ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | croak sprintf "The value passed to the %s attribute does not match the array type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 351 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 7 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||
| 356 | sub fh { | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | if (ref $value ne 'GLOB') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | croak sprintf "The value passed to the %s attribute does not match the glob type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 360 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub build_object { { } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_object: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | sub object { | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | my ($value, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
object: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | if ( ! ref $value || ref $value !~ m/SCALAR|ARRAY|HASH|GLOB/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not ref $value or ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
MC/DC0%0/2
not ref $value or ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
not ref $value
ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
Truth table0%0/3
not(A) or not(B)
A= not ref $valueB= ref !($value =~ /SCALAR|ARRAY|HASH|GLOB/)
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | croak sprintf "The value passed to the %s attribute does not match the object type constraint.", | |||||||||||||||||||||||||||||||||||||||||
| 371 | $name; | ||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | sub deep_clone { | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 211 | ▶ | my ($data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deep_clone: called CC=5 SCAR=16.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | 211 | my $ref = ref $data; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 211 | ▶ | if (!$ref) { return $data; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | elsif ($ref eq 'SCALAR') { my $r = deep_clone($$data); return \$r; } | |||||||||||||||||||||||||||||||||||||||||
| 381 | 22 | elsif ($ref eq 'ARRAY') { return [ map { deep_clone($_) } @{ $data } ]; } | |||||||||||||||||||||||||||||||||||||||||
| 382 | 44 | elsif ($ref eq 'HASH') { return { map +( $_ => deep_clone($data->{$_}) ), keys %{ $data } }; } | |||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||
| 386 | sub deep_clone_ordered_hash { | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 11 | ▶ | my (@hash) = scalar @_ == 1 ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deep_clone_ordered_hash: called CC=3 SCAR=11.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 11 | my %hash = (); | |||||||||||||||||||||||||||||||||||||||||
| 389 | 11 | tie(%hash, 'Tie::IxHash'); | |||||||||||||||||||||||||||||||||||||||||
| 390 | 11 | ▶ | while (@hash) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 33 | my ($key, $value) = (shift @hash, shift @hash); | |||||||||||||||||||||||||||||||||||||||||
| 392 | 33 | $hash{$key} = deep_clone($value) | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 11 | return \%hash; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | sub load { | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 3 | ▶ | my ($module) = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 3 | $module =~ s/\:\:/\//g; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 3 | require $module . '.pm'; | |||||||||||||||||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 6 | 1 | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | __END__ | ||||||||||||||||||||||||||||||||||||||||||