| 1 | package Class::Tiny::Antlers; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | sub _getstash { \%{"$_[0]::"} } | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_getstash: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use 5.006; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | our $AUTHORITY = 'cpan:TOBYINK'; | |||||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | our $VERSION = '0.024'; | |||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use Class::Tiny 0.006 (); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | our @ISA = 'Class::Tiny'; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 11 | my %EXPORT_TAGS = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | default => [qw/ has extends with strict /], | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | all => [qw/ has extends with before after around strict warnings confess /], | ||||||||||||||||||||||||||||||||||||||||||||||
| 18 | cmm => [qw/ before after around /], | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 11 | my %CLASS_ATTRIBUTES; | |||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | sub import | ||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 23 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 23 | my $me = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | my %want = | ||||||||||||||||||||||||||||||||||||||||||||||
| 27 | map +($_ => 1), | ||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 23 | ▶ | map +(@{ $EXPORT_TAGS{substr($_, 1)} or [$_] }), | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$EXPORT_TAGS{substr $_, 1} || [$_]
MC/DC0%0/1
$EXPORT_TAGS{substr $_, 1} || [$_]
$EXPORT_TAGS{substr $_, 1}
Truth table50%1/2
A
A= $EXPORT_TAGS{substr $_, 1}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | (@_ ? @_ : '-default'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 23 | ▶ | strict->import if delete $want{strict}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 23 | ▶ | warnings->import if delete $want{warnings}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 23 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||
| 35 | 23 | ▶ | $me->_install_tracked($caller, has => sub { unshift @_, $me, $caller; goto \&has }) if delete $want{has}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 23 | ▶ | $me->_install_tracked($caller, extends => sub { unshift @_, $me, $caller; goto \&extends }) if delete $want{extends}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 23 | ▶ | $me->_install_tracked($caller, with => sub { unshift @_, $me, $caller; goto \&with }) if delete $want{with}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.1
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 23 | ▶ | $me->_install_tracked($caller, confess => \&confess) if delete $want{confess}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 23 | for my $modifier (qw/ before after around /) | |||||||||||||||||||||||||||||||||||||||||||||
| 41 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 69 | ▶ | next unless delete $want{$modifier}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | $me->_install_tracked($caller, $modifier, sub | ||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | require Class::Method::Modifiers; | |||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | Class::Method::Modifiers::install_modifier($caller, $modifier, @_); | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 9 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 23 | ▶ | croak("Unknown import symbols (%s)", join ", ", sort keys %want) if keys %want; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 23 | @_ = ($me); | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 23 | goto \&Class::Tiny::import; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | my %INSTALLED; | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | sub _install_tracked | ||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 81 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_install_tracked: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 11 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 81 | my ($me, $pkg, $name, $code) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | 81 | *{"$pkg\::$name"} = $code; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 81 | $INSTALLED{$pkg}{$name} = "$code"; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | sub unimport | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unimport: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | my $me = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | my $caller = caller; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | $me->_clean($caller, $INSTALLED{$caller}); | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | sub _clean | ||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_clean: called CC=8 SCAR=21.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | my ($me, $target, $exports) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 3 | ▶ | my %rev = reverse %$exports or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 3 | my $stash = _getstash($target); | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | for my $name (keys %$exports) | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 9 | ▶ | if ($stash->{$name} and defined(&{$stash->{$name}})) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$stash->{$name} and defined &{$stash->{$name};}
MC/DC0%0/2
$stash->{$name} and defined &{$stash->{$name};}
$stash->{$name}
defined &{$stash->{$name};}
Truth table33%1/3
A and B
A= $stash->{$name}B= defined &{$stash->{$name};}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 9 | ▶ | if ($rev{$target->can($name)}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 9 | my $old = delete $stash->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 9 | my $full_name = join('::',$target,$name); | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | # Copy everything except the code slot back into place (e.g. $has) | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 9 | foreach my $type (qw(SCALAR HASH ARRAY IO)) | |||||||||||||||||||||||||||||||||||||||||||||
| 88 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 36 | ▶ | next unless defined(*{$old}{$type}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 11 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 9 | *$full_name = *{$old}{$type}; | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | sub croak | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
croak: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 7 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 101 | 7 | my ($fmt, @values) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 102 | 7 | Carp::croak(sprintf($fmt, @values)); | |||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | sub confess | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
confess: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 1 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | my ($fmt, @values) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | Carp::confess(sprintf($fmt, @values)); | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 11 | my %BUILD_WRAPPED; | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | sub has | ||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 32 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has: called CC=48 SCAR=39.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 32 | my ($me, $caller) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 117 | 32 | my ($attr, %spec) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 32 | ▶ | if (defined($attr) and ref($attr) eq q(ARRAY)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $attr and ref $attr eq "ARRAY"
MC/DC0%0/2
defined $attr and ref $attr eq "ARRAY"
defined $attr
ref $attr eq "ARRAY"
Truth table33%1/3
A and B
A= defined $attrB= ref $attr eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | has($caller, $_, %spec) for @$attr; | |||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 32 | $CLASS_ATTRIBUTES{$caller}{$attr} = +{ %spec }; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | 32 | ▶ | $CLASS_ATTRIBUTES{$caller}{$attr}{is} ||= 'ro'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$CLASS_ATTRIBUTES{$caller}{$attr}{"is"} ||= "ro"
MC/DC100%1/1
$CLASS_ATTRIBUTES{$caller}{$attr}{"is"} ||= "ro"
$CLASS_ATTRIBUTES{$caller}{$attr}{"is"}
Truth table100%2/2
A
A= $CLASS_ATTRIBUTES{$caller}{$attr}{"is"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 32 | ▶ | $CLASS_ATTRIBUTES{$caller}{$attr}{lazy} ||= 1 if exists($spec{default}); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$CLASS_ATTRIBUTES{$caller}{$attr}{"lazy"} ||= 1
MC/DC100%1/1
$CLASS_ATTRIBUTES{$caller}{$attr}{"lazy"} ||= 1
$CLASS_ATTRIBUTES{$caller}{$attr}{"lazy"}
Truth table100%2/2
A
A= $CLASS_ATTRIBUTES{$caller}{$attr}{"lazy"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 32 | ▶ | if (!defined($attr) or ref($attr) or $attr !~ /^[^\W\d]\w*$/s) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $attr or ref $attr or not $attr =~ /^[^\W\d]\w*$/s
not defined $attr or ref $attr
MC/DC0%0/3
not defined $attr or ref $attr or not $attr =~ /^[^\W\d]\w*$/s
not defined $attr
ref $attr
not $attr =~ /^[^\W\d]\w*$/s
Truth table25%1/4
not(A) or B or not(C)
A= not defined $attrB= ref $attrC= not $attr =~ /^[^\W\d]\w*$/s
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | croak("Invalid accessor name '%s'", $attr); | |||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 32 | ▶ | my $init_arg = exists($spec{init_arg}) ? delete($spec{init_arg}) : \undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 32 | ▶ | my $is = delete($spec{is}) || 'rw'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $spec{'is'} || 'rw'
MC/DC100%1/1
delete $spec{'is'} || 'rw'
delete $spec{'is'}
Truth table100%2/2
A
A= delete $spec{'is'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 32 | my $required = delete($spec{required}); | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | 32 | my $default = delete($spec{default}); | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | 32 | my $lazy = delete($spec{lazy}); | |||||||||||||||||||||||||||||||||||||||||||||
| 139 | 32 | my $clearer = delete($spec{clearer}); | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | 32 | my $predicate = delete($spec{predicate}); | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 32 | my $setter_wrap; | |||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 32 | ▶ | if ($spec{isa} or $spec{coerce}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$spec{"isa"} or $spec{"coerce"}
MC/DC50%1/2
$spec{"isa"} or $spec{"coerce"}
$spec{"isa"}
$spec{"coerce"}
Truth table66%2/3
A or B
A= $spec{"isa"}B= $spec{"coerce"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 1 | ▶ | ref($spec{isa}) or croak("Type names are strings are not supported"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | ▶ | $spec{isa}->can('check') or croak("Type doesn't have a `check` method"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | $spec{isa}->can('get_message') or croak("Type doesn't have a `get_message` method"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | ▶ | $spec{isa}->can('coerce') or !$spec{coerce} or croak("Type doesn't have a `coerce` method"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$spec{"isa"}->can("coerce") or not $spec{"coerce"}
MC/DC0%0/2
$spec{"isa"}->can("coerce") or not $spec{"coerce"}
$spec{"isa"}->can("coerce")
not $spec{"coerce"}
Truth table33%1/3
A or not(B)
A= $spec{"isa"}->can("coerce")B= not $spec{"coerce"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | $setter_wrap = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | delete $spec{$_} for qw/ isa coerce /; | |||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | __PACKAGE__->_wrap_build($caller) unless $BUILD_WRAPPED{$caller}++; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 32 | ▶ | if ($is eq 'lazy') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $lazy = 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $is = 'ro'; | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 32 | ▶ | if (defined $lazy and not $lazy) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $lazy and not $lazy
MC/DC100%2/2
defined $lazy and not $lazy
defined $lazy
not $lazy
Truth table100%3/3
A and not(B)
A= defined $lazyB= not $lazy
| |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | croak("Class::Tiny does not support eager defaults"); | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 164 | elsif (keys %spec) | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | croak("Unknown options in attribute specification (%s)", join ", ", sort keys %spec); | |||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 30 | ▶ | if ($required and 'Class::Tiny::Object'->can('new') == $caller->can('new')) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$required and "Class::Tiny::Object"->can("new") == $caller->can("new")
MC/DC100%2/2
$required and "Class::Tiny::Object"->can("new") == $caller->can("new")
$required
"Class::Tiny::Object"->can("new") == $caller->can("new")
Truth table100%3/3
A and B
A= $requiredB= "Class::Tiny::Object"->can("new") == $caller->can("new")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | croak("Class::Tiny::Object::new does not support required attributes; please manually override the constructor to enforce required attributes"); | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 29 | ▶ | if ($init_arg and ref($init_arg) eq 'SCALAR' and not defined $$init_arg) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
$init_arg and ref $init_arg eq "SCALAR" and not defined $$init_arg
$init_arg and ref $init_arg eq "SCALAR"
MC/DC66%2/3
$init_arg and ref $init_arg eq "SCALAR" and not defined $$init_arg
$init_arg
ref $init_arg eq "SCALAR"
not defined $$init_arg
Truth table75%3/4
A and B and not(C)
A= $init_argB= ref $init_arg eq "SCALAR"C= not defined $$init_arg
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | # ok | ||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ▶ | elsif (!$init_arg or $init_arg ne $attr) | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
not $init_arg or $init_arg ne $attr
MC/DC100%2/2
not $init_arg or $init_arg ne $attr
not $init_arg
$init_arg ne $attr
Truth table100%3/3
not(A) or B
A= not $init_argB= $init_arg ne $attr
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | croak("Class::Tiny does not support init_arg"); | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 27 | my $getter = "\$_[0]{'$attr'}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 184 | 27 | ▶ | if (defined $default and ref($default) eq 'CODE') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $default and ref $default eq "CODE"
MC/DC100%2/2
defined $default and ref $default eq "CODE"
defined $default
ref $default eq "CODE"
Truth table100%3/3
A and B
A= defined $defaultB= ref $default eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 6 | $getter = "\$_[0]{'$attr'} = \$default->(\$_[0]) unless exists \$_[0]{'$attr'}; $getter"; | |||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | elsif (defined $default) | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 9 | $getter = "\$_[0]{'$attr'} = \$default unless exists \$_[0]{'$attr'}; $getter"; | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 27 | my $setter_name; | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | my @methods; | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 27 | my $needs_clean = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 196 | 27 | ▶ | if ($is eq 'rw') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 14 | $setter_name = $attr; | |||||||||||||||||||||||||||||||||||||||||||||
| 199 | 14 | push @methods, "sub $attr :method { \$_[0]{'$attr'} = \$_[1] if \@_ > 1; $getter };"; | |||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ▶ | elsif ($is eq 'ro' or $is eq 'rwp') | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$is eq "ro" or $is eq "rwp"
MC/DC100%2/2
$is eq "ro" or $is eq "rwp"
$is eq "ro"
$is eq "rwp"
Truth table100%3/3
A or B
A= $is eq "ro"B= $is eq "rwp"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 12 | $setter_name = "_set_$attr"; | |||||||||||||||||||||||||||||||||||||||||||||
| 204 | 12 | push @methods, "sub $attr :method { $getter };"; | |||||||||||||||||||||||||||||||||||||||||||||
| 205 | 12 | ▶ | push @methods, "sub _set_$attr :method { \$_[0]{'$attr'} = \$_[1] };" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 206 | if $is eq 'rwp'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | elsif ($is eq 'bare') | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 11 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | $needs_clean = not exists &{"$caller\::$attr"}; | |||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | else | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | croak("Class::Tiny::Antlers does not support '$is' accessors"); | |||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 27 | ▶ | if ($clearer) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | $clearer = ($attr =~ /^_/) ? "_clear$attr" : "clear_$attr" if $clearer eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 3 | push @methods, "sub $clearer :method { delete(\$_[0]{'$attr'}) }"; | |||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 27 | ▶ | if ($predicate) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 4 | ▶ | $predicate = ($attr =~ /^_/) ? "_has$attr" : "has_$attr" if $predicate eq '1'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 4 | push @methods, "sub $predicate :method { exists(\$_[0]{'$attr'}) }"; | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 27 | ▶ | eval "package $caller; @methods"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_ccc: called CC=1 SCAR=0.0
Subroutine
aaa: called CC=2 SCAR=6.9
Subroutine
bbb: called CC=3 SCAR=11.0
Subroutine
ccc: called CC=2 SCAR=6.9
Subroutine
eee: called CC=2 SCAR=6.9
Subroutine
_set_ccc: called CC=1 SCAR=0.0
Subroutine
_set_ccc: called CC=1 SCAR=0.0
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 27 | $me->create_attributes($caller, $attr); | |||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 27 | ▶ | $me->_wrap_setter($caller, $attr, $setter_name) if $setter_wrap; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 11 | ▶ | $me->_clean($caller, { $attr => do { no strict 'refs'; ''.\&{"$caller\::$attr"} } }) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 236 | if $needs_clean; | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 1 | ▶ | sub _wrap_build { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap_build: called CC=2 SCAR=8.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1 | my ($me, $caller) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 241 | 11 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 1 | ▶ | if (exists &{"$caller\::BUILD"}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | my $next = \&{"$caller\::BUILD"}; | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | $me->_clean($caller, { BUILD => $next }); | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | eval sprintf(q{ | |||||||||||||||||||||||||||||||||||||||||||||
| 246 | package %s; | ||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||
| 248 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | %s->_check_args('%s', @_); | ||||||||||||||||||||||||||||||||||||||||||||||
| 250 | $self->$next(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | }, $caller, $me, $caller); | ||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | eval sprintf(q{ | |||||||||||||||||||||||||||||||||||||||||||||
| 256 | package %s; | ||||||||||||||||||||||||||||||||||||||||||||||
| 257 | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | %s->_check_args('%s', $self, @_); | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 261 | }, $caller, $me, $caller); | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | ▶ | sub _check_args { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_check_args: called CC=7 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | my ($me, $caller, $object, $args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | my $spec = $CLASS_ATTRIBUTES{$caller}; | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | for my $attr (sort keys %$spec) { | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | ▶ | my $type = $spec->{$attr}{isa} or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | ▶ | exists $args->{$attr} or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 2 | ▶ | $type->check($args->{$attr}) and next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 1 | ▶ | if ($spec->{$attr}{coerce}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | my $coerced = $type->coerce($args->{$attr}); | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | ▶ | if ($type->check($coerced)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $object->{$attr} = $args->{$attr} = $coerced; | |||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1 | croak('Type constraint check failed for attribute "%s": %s', $attr, $type->get_message($args->{$attr})); | |||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 1 | ▶ | sub _wrap_setter { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_wrap_setter: called CC=5 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 1 | my ($me, $caller, $attr, $setter_name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 11 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 1 | my $next = \&{"$caller\::$setter_name"}; | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | 1 | my $spec = $CLASS_ATTRIBUTES{$caller}; | |||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | my $type = $spec->{$attr}{isa}; | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | my $coerce = $spec->{$attr}{coerce}; | |||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | $me->_clean($caller, { $setter_name => $next }); | |||||||||||||||||||||||||||||||||||||||||||||
| 291 | 1 | ▶ | if ($coerce) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 1 | ▶ | eval sprintf(q{ | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$type->check(@_) or do {
my $coerced = $type->coerce(@_);
$type->check($coerced) and do {
@_ = $coerced;
1
}
}
MC/DC0%0/2
$type->check(@_) or do {
my $coerced = $type->coerce(@_);
$type->check($coerced) and do {
@_ = $coerced;
1
}
}
$type->check(@_)
do {
my $coerced = $type->coerce(@_);
$type->check($coerced) and do {
@_ = $coerced;
1
}
}
Truth table0%0/3
A or B
A= $type->check(@_)B= do {
my $coerced = $type->coerce(@_);
$type->check($coerced) and do {
@_ = $coerced;
1
}
}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | package %s; | ||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub %s { | ||||||||||||||||||||||||||||||||||||||||||||||
| 295 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | $type->check(@_) | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | or do { | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | my $coerced = $type->coerce(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
| 300 | $type->check($coerced) and do { @_ = ($coerced); 1 }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 302 | or %s::croak('Type constraint check failed for attribute "%s": %%s', $type->get_message(@_)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | $self->$next(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 306 | }, $caller, $setter_name, $me, $attr); | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 308 | ▶ | elsif ($type->can('can_be_inlined') && $type->can_be_inlined) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$type->can("can_be_inlined") and $type->can_be_inlined
MC/DC0%0/2
$type->can("can_be_inlined") and $type->can_be_inlined
$type->can("can_be_inlined")
$type->can_be_inlined
Truth table0%0/3
A and B
A= $type->can("can_be_inlined")B= $type->can_be_inlined
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $ic = $type->can('inline_check') || $type->can('_inline_check'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$type->can('inline_check') || $type->can('_inline_check')
MC/DC0%0/2
$type->can('inline_check') || $type->can('_inline_check')
$type->can('inline_check')
$type->can('_inline_check')
Truth table0%0/3
A || B
A= $type->can('inline_check')B= $type->can('_inline_check')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | eval sprintf(q{ | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | package %s; | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | sub %s { | ||||||||||||||||||||||||||||||||||||||||||||||
| 313 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 314 | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 315 | my $val = $_[0]; | ||||||||||||||||||||||||||||||||||||||||||||||
| 316 | %s or %s::croak('Type constraint check failed for attribute "%s": %%s', $type->get_message(@_)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | $self->$next(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 320 | }, $caller, $setter_name, $type->$ic('$val'), $me, $attr); | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | eval sprintf(q{ | |||||||||||||||||||||||||||||||||||||||||||||
| 324 | package %s; | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | sub %s { | ||||||||||||||||||||||||||||||||||||||||||||||
| 326 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
| 327 | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 328 | $type->check(@_) or %s::croak('Type constraint check failed for attribute "%s": %%s', $type->get_message(@_)); | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 330 | $self->$next(@_); | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | }, $caller, $setter_name, $me, $attr); | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | sub extends | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 11 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extends: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 11 | my ($me, $caller) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | 11 | my (@parents) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 8 | for my $parent (@parents) | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 8 | eval "require $parent"; | |||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 11 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 7 | @{"$caller\::ISA"} = @parents; | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | sub with | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
with: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 3 | my ($me, $caller) = (shift, shift); | |||||||||||||||||||||||||||||||||||||||||||||
| 353 | 7 | require Role::Tiny::With; | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | 2 | goto \&Role::Tiny::With::with; | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | sub get_all_attribute_specs_for | ||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_all_attribute_specs_for: not called CC=6 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | my $me = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $class = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my %specs = %{ $me->get_all_attribute_defaults_for }; | |||||||||||||||||||||||||||||||||||||||||||||
| 363 | $specs{$_} = | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | defined($specs{$_}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ? +{ is => 'rw', lazy => 1, default => $specs{$_} } | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | : +{ is => 'rw' } | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | for keys %specs; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | for my $p ( reverse @{ $class->mro::get_linear_isa } ) | |||||||||||||||||||||||||||||||||||||||||||||
| 370 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | while ( my ($k, $v) = each %{$CLASS_ATTRIBUTES{$p}||{}} ) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$CLASS_ATTRIBUTES{$p} || {}
MC/DC100%1/1
$CLASS_ATTRIBUTES{$p} || {}
$CLASS_ATTRIBUTES{$p}
Truth table100%2/2
A
A= $CLASS_ATTRIBUTES{$p}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | { | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | $specs{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | \%specs; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||