| 1 | 13 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | package Class::Accessor::Complex; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 13 | our $VERSION = '1.100880'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # ABSTRACT: Arrays, hashes, booleans, integers, sets and more | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Carp qw(carp croak cluck); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 13 | ▶ | use Data::Miscellany 'flatten'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use List::MoreUtils 'uniq'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 13 | ▶ | use parent qw(Class::Accessor Class::Accessor::Installer); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 14 | ▶ | sub mk_new { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_new: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 14 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 14 | ▶ | @args = ('new') unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 14 | for my $name (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 16 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=8 SCAR=25.3
Subroutine
new: not called CC=8 SCAR=25.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 16 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # don't use $class, as that's already defined above | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 16 | my $this_class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 16 | ▶ | my $self = ref($this_class) ? $this_class : bless {}, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | $this_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | my %args = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | (scalar(@_ == 1) && ref($_[0]) eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | ? %{ $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
scalar(@_ == 1) and ref $_[0] eq "HASH"
scalar(@_ == 1) and ref $_[0] eq "HASH"
MC/DC0%0/2
scalar(@_ == 1) and ref $_[0] eq "HASH"
scalar(@_ == 1)
ref $_[0] eq "HASH"
MC/DC0%0/2
scalar(@_ == 1) and ref $_[0] eq "HASH"
scalar(@_ == 1)
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= scalar(@_ == 1)B= ref $_[0] eq "HASH"
Truth table0%0/3
A and B
A= scalar(@_ == 1)B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $self->$_($args{$_}) for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $self->init(%args) if $self->can('init'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 16 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 14 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | Creates and returns a new object. The constructor will accept as arguments a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | list of pairs, from component name to initial value. For each pair, the named | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | component is initialized by calling the method of the same name with the given | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | value. If called with a single hash reference, it is dereferenced and its | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | key/value pairs are set as described before. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | "my \$obj = $class->$name;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | "my \$obj = $class->$name(\%args);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 14 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 1 | ▶ | sub mk_singleton { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_singleton: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | @args = ('new') unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | my $singleton; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | for my $name (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=25.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 3 | ▶ | return $singleton if defined $singleton; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # don't use $class, as that's already defined above | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | my $this_class = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 1 | ▶ | $singleton = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ref($this_class) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ? $this_class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | : bless {}, $this_class; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | my %args = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | (scalar(@_ == 1) && ref($_[0]) eq 'HASH') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | ? %{ $_[0] } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
scalar(@_ == 1) and ref $_[0] eq "HASH"
MC/DC0%0/2
scalar(@_ == 1) and ref $_[0] eq "HASH"
scalar(@_ == 1)
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= scalar(@_ == 1)B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | : @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | $singleton->$_($args{$_}) for keys %args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | ▶ | $singleton->init(%args) if $singleton->can('init'); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | $singleton; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | Creates and returns a new object. The object will be a singleton, so repeated | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | calls to the constructor will always return the same object. The constructor | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | will accept as arguments a list of pairs, from component name to initial | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | value. For each pair, the named component is initialized by calling the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | method of the same name with the given value. If called with a single hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | reference, it is dereferenced and its key/value pairs are set as described | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | before. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | "my \$obj = $class->$name;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | "my \$obj = $class->$name(\%args);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 3 | ▶ | sub mk_scalar_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_scalar_accessors: called CC=4 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 3 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 3 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 3 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 14 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 14 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 14 | ▶ | return $_[0]->{$field} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 5 | $_[0]->{$field} = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | A basic getter/setter method. If called without an argument, it returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | value. If called with a single argument, it sets the value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | examples => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | [ "my \$value = \$obj->$field;", "\$obj->$field(\$value);", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 4 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $_[0]->{$field} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 4 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | purpose => 'Clears the value.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | examples => ["\$obj->$clear_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 3 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | ▶ | sub mk_class_scalar_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_class_scalar_accessors: called CC=4 SCAR=15.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | my $scalar; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 5 | ▶ | return $scalar if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | $scalar = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 1 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | A basic getter/setter method. This is a class variable, so it is shared | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | between all instances of this class. Changing it in one object will change it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | for all other objects as well. If called without an argument, it returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | value. If called with a single argument, it sets the value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | examples => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | [ "my \$value = \$obj->$field;", "\$obj->$field(\$value);", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 1 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $scalar = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | Clears the value. Since this is a class variable, the value will be undefined | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | example => "\$obj->$clear_methods[0];", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 1 | ▶ | sub mk_concat_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_concat_accessors: called CC=5 SCAR=23.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | for my $arg (@args) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # defaults | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | my $field = $arg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | my $join = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 2 | ▶ | if (ref $arg eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ($field, $join) = @$arg; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my ($self, $text) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if (defined $text) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | ▶ | if (defined $self->{$field}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $self->{$field} = $self->{$field} . $join . $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->{$field} = $text; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | return $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 2 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # FIXME use the current value of $join in the docs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | A getter/setter method. If called without an argument, it returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | value. If called with a single argument, it appends to the current value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | examples => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | [ "my \$value = \$obj->$field;", "\$obj->$field(\$value);", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $_[0]->{$field} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | Clears the value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | example => "\$obj->$clear_methods[0];", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 1 | ▶ | sub mk_array_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_array_accessors: called CC=12 SCAR=31.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 6 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 6 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 6 | my ($self, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 6 | ▶ | defined $self->{$field} or $self->{$field} = []; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 1 | @{ $self->{$field} } = | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 6 | ▶ | map { ref $_ eq 'ARRAY' ? @$_ : ($_) } @list | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | if @list; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 6 | ▶ | wantarray ? @{ $self->{$field} } : $self->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | Get or set the array values. If called without arguments, it returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | array in list context, or a reference to the array in scalar context. If | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | called with arguments, it expands array references found therein and sets the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | values. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | "my \@values = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | "my \$array_ref = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | "\$obj->$field(\@values);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | "\$obj->$field(\$array_ref);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | my @push_methods = uniq "push_${field}", "${field}_push"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | for my $name (@push_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | push @{ $self->{$field} } => @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 1 | name => \@push_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | purpose => 'Pushes elements onto the end of the array.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | examples => ["\$obj->$push_methods[0](\@values);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | my @pop_methods = uniq "pop_${field}", "${field}_pop"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | for my $name (@pop_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | pop @{ $_[0]->{$field} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 1 | name => \@pop_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | Pops the last element off the array, returning it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | examples => ["my \$value = \$obj->$pop_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | my @unshift_methods = uniq "unshift_${field}", "${field}_unshift"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | for my $name (@unshift_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | unshift @{ $self->{$field} } => @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | name => \@unshift_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | Unshifts elements onto the beginning of the array. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | examples => ["\$obj->$unshift_methods[0](\@values);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 1 | my @shift_methods = uniq "shift_${field}", "${field}_shift"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | for my $name (@shift_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | shift @{ $_[0]->{$field} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 1 | name => \@shift_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | Shifts the first element off the array, returning it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | examples => ["my \$value = \$obj->$shift_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 1 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 1 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | $_[0]->{$field} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 1 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | Deletes all elements from the array. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | examples => ["\$obj->$clear_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1 | my @count_methods = uniq "count_${field}", "${field}_count"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | for my $name (@count_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 6 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 6 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 6 | ▶ | exists $_[0]->{$field} ? scalar @{ $_[0]->{$field} } : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 1 | name => \@count_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | Returns the number of elements in the array. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | examples => ["my \$count = \$obj->$count_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 1 | my @splice_methods = uniq "splice_${field}", "${field}_splice"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 1 | for my $name (@splice_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1 | my ($self, $offset, $len, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | splice(@{ $self->{$field} }, $offset, $len, @list); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | name => \@splice_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | Takes three arguments: An offset, a length and a list. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | Removes the elements designated by the offset and the length from the array, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | and replaces them with the elements of the list, if any. In list context, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | returns the elements removed from the array. In scalar context, returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | last element removed, or C<undef> if no elements are removed. The array grows | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | or shrinks as necessary. If the offset is negative then it starts that far | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | from the end of the array. If the length is omitted, removes everything from | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | the offset onward. If the length is negative, removes the elements from the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | offset onward except for -length elements at the end of the array. If both the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | offset and the length are omitted, removes everything. If the offset is past | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | the end of the array, it issues a warning, and splices at the end of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | array. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | "\$obj->$splice_methods[0](2, 1, \$x, \$y);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | "\$obj->$splice_methods[0](-1);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | "\$obj->$splice_methods[0](0, -1);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | my @index_methods = uniq "index_${field}", "${field}_index"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | for my $name (@index_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 3 | my ($self, @indices) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 3 | my @result = map { $self->{$field}[$_] } @indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 3 | ▶ | return $result[0] if @indices == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | ▶ | wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | name => \@index_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | Takes a list of indices and returns the elements indicated by those indices. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | If only one index is given, the corresponding array element is returned. If | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | several indices are given, the result is returned as an array in list context | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | or as an array reference in scalar context. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | "my \$element = \$obj->$index_methods[0](3);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | "my \@elements = \$obj->$index_methods[0](\@indices);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | "my \$array_ref = \$obj->$index_methods[0](\@indices);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 1 | my @set_methods = uniq "set_${field}", "${field}_set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 1 | for my $name (@set_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${$name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | ▶ | croak | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | "${class}::${field}_set expects an even number of fields\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | if @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | while (my ($index, $value) = splice @args, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $self->{$field}->[$index] = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | return @_ / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | name => \@set_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | Takes a list of index/value pairs and for each pair it sets the array element | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | at the indicated index to the indicated value. Returns the number of elements | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | that have been set. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | examples => ["\$obj->$set_methods[0](1 => \$x, 5 => \$y);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 1 | ▶ | sub mk_class_array_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_class_array_accessors: called CC=12 SCAR=30.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 1 | my @array; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 16 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 16 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 16 | my ($self, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 16 | ▶ | @array = map { ref $_ eq 'ARRAY' ? @$_ : ($_) } @list | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | if @list; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 16 | ▶ | wantarray ? @array : \@array; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 1 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | Get or set the array values. If called without an arguments, it returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | array in list context, or a reference to the array in scalar context. If | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | called with arguments, it expands array references found therein and sets the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | values. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | This is a class variable, so it is shared between all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | Changing it in one object will change it for all other objects as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | "my \@values = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | "my \$array_ref = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | "\$obj->$field(\@values);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | "\$obj->$field(\$array_ref);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | my @push_methods = uniq "push_${field}", "${field}_push"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 1 | for my $name (@push_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 1 | push @array => @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | name => \@push_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | Pushes elements onto the end of the array. Since this is a class variable, the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | examples => ["\$obj->$push_methods[0](\@values);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1 | my @pop_methods = uniq "pop_${field}", "${field}_pop"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1 | for my $name (@pop_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 1 | pop @array; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | name => \@pop_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | Pops the last element off the array, returning it. Since this is a class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | variable, the value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | examples => ["my \$value = \$obj->$pop_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1 | my @field_methods = uniq "unshift_${field}", "${field}_unshift"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | for my $name (@field_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | unshift @array => @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 1 | name => \@field_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | Unshifts elements onto the beginning of the array. Since this is a class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | variable, the value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | examples => ["\$obj->$field_methods[0](\@values);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | my @shift_methods = uniq "shift_${field}", "${field}_shift"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 1 | for my $name (@shift_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 1 | shift @array; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 1 | name => \@shift_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | Shifts the first element off the array, returning it. Since this is a class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | variable, the value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | examples => ["my \$value = \$obj->$shift_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 1 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 1 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | @array = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | Deletes all elements from the array. Since this is a class variable, the value | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | examples => ["\$obj->$clear_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 1 | my @count_methods = uniq "count_${field}", "${field}_count"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | for my $name (@count_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 6 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 6 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 6 | scalar @array; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | name => \@count_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | Returns the number of elements in the array. Since this is a class variable, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | the value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | examples => ["my \$count = \$obj->$count_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 1 | my @splice_methods = uniq "splice_${field}", "${field}_splice"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | for my $name (@splice_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 1 | my ($self, $offset, $len, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 1 | splice(@array, $offset, $len, @list); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 1 | name => \@splice_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | Takes three arguments: An offset, a length and a list. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | Removes the elements designated by the offset and the length from the array, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | and replaces them with the elements of the list, if any. In list context, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | returns the elements removed from the array. In scalar context, returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | last element removed, or C<undef> if no elements are removed. The array grows | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | or shrinks as necessary. If the offset is negative then it starts that far | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | from the end of the array. If the length is omitted, removes everything from | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | the offset onward. If the length is negative, removes the elements from the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | offset onward except for -length elements at the end of the array. If both the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | offset and the length are omitted, removes everything. If the offset is past | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | the end of the array, it issues a warning, and splices at the end of the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | array. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | Since this is a class variable, the value will be changed for all instances of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | "\$obj->$splice_methods[0](2, 1, \$x, \$y);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | "\$obj->$splice_methods[0](-1);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | "\$obj->$splice_methods[0](0, -1);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 1 | my @index_methods = uniq "index_${field}", "${field}_index"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 1 | for my $name (@index_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 3 | my ($self, @indices) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 3 | my @result = map { $array[$_] } @indices; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 3 | ▶ | return $result[0] if @indices == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 1 | ▶ | wantarray ? @result : \@result; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | name => \@index_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | Takes a list of indices and returns the elements indicated by those indices. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | If only one index is given, the corresponding array element is returned. If | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | several indices are given, the result is returned as an array in list context | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | or as an array reference in scalar context. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | Since this is a class variable, the value will be changed for all instances of | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | "my \$element = \$obj->$index_methods[0](3);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | "my \@elements = \$obj->$index_methods[0](\@indices);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | "my \$array_ref = \$obj->$index_methods[0](\@indices);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 1 | my @set_methods = uniq "set_${field}", "${field}_set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 1 | for my $name (@set_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | croak | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | "${class}::${field}_set expects an even number of fields\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | if @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | while (my ($index, $value) = splice @args, 0, 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 0 | $array[$index] = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | return @_ / 2; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 1 | name => \@set_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | Takes a list of index/value pairs and for each pair it sets the array element | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | at the indicated index to the indicated value. Returns the number of elements | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | that have been set. Since this is a class variable, the value will be changed | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | examples => ["\$obj->$set_methods[0](1 => \$x, 5 => \$y);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 1 | ▶ | sub mk_hash_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_hash_accessors: called CC=9 SCAR=23.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | 9 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=13 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 9 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 9 | my ($self, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 9 | ▶ | defined $self->{$field} or $self->{$field} = {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 9 | ▶ | if (scalar @list == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 3 | my ($key) = @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 3 | ▶ | if (my $type = ref $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 2 | ▶ | if ($type eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 1 | return @{ $self->{$field} }{@$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | } elsif ($type eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 1 | ▶ | while (my ($subkey, $value) = each %$key) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 2 | $self->{$field}{$subkey} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | return wantarray | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | ? %{ $self->{$field} } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 1 | ▶ | : $self->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 0 | cluck | |||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | "Unrecognized ref type for hash method: $type."; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 1 | return $self->{$field}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 6 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 10 | my $key = shift @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 10 | ▶ | defined $key or last; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 4 | my $value = shift @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 4 | ▶ | defined $value or carp "No value for key $key."; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 4 | $self->{$field}{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 6 | ▶ | return wantarray ? %{ $self->{$field} } : $self->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 1 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | Get or set the hash values. If called without arguments, it returns the hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | in list context, or a reference to the hash in scalar context. If called | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | with a list of key/value pairs, it sets each key to its corresponding value, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | then returns the hash as described before. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | If called with exactly one key, it returns the corresponding value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | If called with exactly one array reference, it returns an array whose elements | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | are the values corresponding to the keys in the argument array, in the same | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | order. The resulting list is returned as an array in list context, or a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | reference to the array in scalar context. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | If called with exactly one hash reference, it updates the hash with the given | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | key/value pairs, then returns the hash in list context, or a reference to the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | hash in scalar context. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | "my \%hash = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | "my \$hash_ref = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | "my \$value = \$obj->$field(\$key);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | "my \@values = \$obj->$field([ qw(foo bar) ]);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | "\$obj->$field(\%other_hash);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | "\$obj->$field(foo => 23, bar => 42);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 1 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 1 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | $self->{$field} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 1 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | Deletes all keys and values from the hash. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | examples => ["\$obj->$clear_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 1 | my @keys_methods = uniq "keys_${field}", "${field}_keys"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 1 | for my $name (@keys_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 3 | keys %{ $_[0]->{$field} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 1 | name => \@keys_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | Returns a list of all hash keys in no particular order. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | examples => ["my \@keys = \$obj->$keys_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 1 | my @count_methods = uniq "count_${field}", "${field}_count"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 1 | for my $name (@count_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 3 | scalar keys %{ $_[0]->{$field} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 1 | name => \@count_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | Returns the number of keys in the hash. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | examples => ["my \$count = \$obj->$count_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 1 | my @values_methods = uniq "values_${field}", "${field}_values"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 1 | for my $name (@values_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 1 | values %{ $_[0]->{$field} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | 1 | name => \@values_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | Returns a list of all hash values in no particular order. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | examples => ["my \@values = \$obj->$values_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 1 | my @exists_methods = uniq "exists_${field}", "${field}_exists"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 1 | for my $name (@exists_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 3 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 3 | ▶ | exists $self->{$field} && exists $self->{$field}{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 1 | name => \@exists_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | Takes a key and returns a true value if the key exists in the hash, and a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | false value otherwise. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | examples => ["if (\$obj->$exists_methods[0](\$key)) { ... }"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 1 | my @delete_methods = uniq "delete_${field}", "${field}_delete"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 1 | for my $name (@delete_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 1 | my ($self, @keys) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 1 | delete @{ $self->{$field} }{@keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 1 | name => \@delete_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | purpose => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 'Takes a list of keys and deletes those keys from the hash.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | examples => ["\$obj->$delete_methods[0](\@keys);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 1 | ▶ | sub mk_class_hash_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_class_hash_accessors: called CC=8 SCAR=21.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 1 | my %hash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 10 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=11 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 10 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 10 | my ($self, @list) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 10 | ▶ | if (scalar @list == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 3 | my ($key) = @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 3 | ▶ | return $hash{$key} unless ref $key; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 2 | ▶ | return @hash{@$key} if ref $key eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | 1 | ▶ | if (ref($key) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 1 | %hash = (%hash, %$key); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 1 | ▶ | return wantarray ? %hash : \%hash; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | # not a scalar, array or hash... | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | 0 | cluck sprintf | |||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 'Not a recognized ref type for static hash [%s]', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | ref($key); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 7 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 11 | my $key = shift @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | 11 | ▶ | defined $key or last; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 4 | my $value = shift @list; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 4 | ▶ | defined $value or carp "No value for key $key."; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 4 | $hash{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 7 | ▶ | return wantarray ? %hash : \%hash; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 1 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | Get or set the hash values. If called without arguments, it returns the hash | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | in list context, or a reference to the hash in scalar context. If called | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | with a list of key/value pairs, it sets each key to its corresponding value, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | then returns the hash as described before. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | If called with exactly one key, it returns the corresponding value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | If called with exactly one array reference, it returns an array whose elements | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | are the values corresponding to the keys in the argument array, in the same | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | order. The resulting list is returned as an array in list context, or a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | reference to the array in scalar context. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | If called with exactly one hash reference, it updates the hash with the given | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | key/value pairs, then returns the hash in list context, or a reference to the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | hash in scalar context. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | This is a class variable, so it is shared between all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | Changing it in one object will change it for all other objects as well. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | "my \%hash = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | "my \$hash_ref = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | "my \$value = \$obj->$field(\$key);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | "my \@values = \$obj->$field([ qw(foo bar) ]);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | "\$obj->$field(\%other_hash);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | "\$obj->$field(foo => 23, bar => 42);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 1 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 1 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 1 | %hash = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 1 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | Deletes all keys and values from the hash. Since this is a class variable, the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | examples => ["\$obj->$clear_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 1 | my @keys_methods = uniq "keys_${field}", "${field}_keys"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | 1 | for my $name (@keys_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 3 | keys %hash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 1 | name => \@keys_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | Returns a list of all hash keys in no particular order. Since this is a class | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | variable, the value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | examples => ["my \@keys = \$obj->$keys_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 1 | my @values_methods = uniq "values_${field}", "${field}_values"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 1 | for my $name (@values_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 1 | values %hash; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 1 | name => \@values_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | Returns a list of all hash values in no particular order. Since this is a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | class variable, the value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | examples => ["my \@values = \$obj->$values_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 1 | my @exists_methods = uniq "exists_${field}", "${field}_exists"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 1 | for my $name (@exists_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 3 | exists $hash{ $_[1] }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 1 | name => \@exists_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | Takes a key and returns a true value if the key exists in the hash, and a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | false value otherwise. Since this is a class variable, the value will be | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | examples => ["if (\$obj->$exists_methods[0](\$key)) { ... }"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 1 | my @delete_methods = uniq "delete_${field}", "${field}_delete"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 1 | for my $name (@delete_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 1 | my ($self, @keys) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 1 | delete @hash{@keys}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 1 | name => \@delete_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | Takes a list of keys and deletes those keys from the hash. Since this is a | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | class variable, the value will be changed for all instances of this class. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | examples => ["\$obj->$delete_methods[0](\@keys);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 1 | ▶ | sub mk_abstract_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_abstract_accessors: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 1 | my $method = "${class}::${field}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 1 | eval "require Error::Hierarchy::Internal::AbstractMethod"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | # Error::Hierarchy not installed? | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 1 | die sprintf "called abstract method [%s]", $method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | # need to pass method because caller() still doesn't see the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | # anonymously named sub's name | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | throw Error::Hierarchy::Internal::AbstractMethod( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | method => $method,); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 0 | ▶ | sub mk_boolean_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_boolean_accessors: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 0 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 0 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table0%0/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 0 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 0 | ▶ | return $_[0]->{$field} if @_ == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 0 | ▶ | $_[0]->{$field} = $_[1] ? 1 : 0; # normalize | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 0 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | If called without an argument, returns the boolean value (0 or 1). If called | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | with an argument, it normalizes it to the boolean value. That is, the values | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 0, undef and the empty string become 0; everything else becomes 1. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | examples => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | [ "\$obj->$field(\$value);", "my \$value = \$obj->$field;", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 0 | my @set_methods = uniq "set_${field}", "${field}_set"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 0 | for my $name (@set_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 0 | $_[0]->{$field} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 0 | name => \@set_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | purpose => 'Sets the boolean value to 1.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | examples => ["\$obj->$set_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 0 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 0 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 0 | $_[0]->{$field} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | purpose => 'Clears the boolean value by setting it to 0.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | examples => ["\$obj->$clear_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 0 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 1 | ▶ | sub mk_integer_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_integer_accessors: called CC=6 SCAR=21.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 9 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 9 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | 9 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 9 | ▶ | return $self->{$field} || 0 unless @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$self->{$field} || 0
MC/DC100%1/1
$self->{$field} || 0
$self->{$field}
Truth table100%2/2
A
A= $self->{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 2 | $self->{$field} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 2 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | A basic getter/setter method. If called without an argument, it returns the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | value, or 0 if there is no previous value. If called with a single argument, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | it sets the value. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | examples => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | [ "\$obj->$field(\$value);", "my \$value = \$obj->$field;", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 2 | my @reset_methods = uniq "reset_${field}", "${field}_reset"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 2 | for my $name (@reset_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=18.4
Subroutine
reset_reset: called CC=3 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 0 | $_[0]->{$field} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 2 | name => \@reset_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | purpose => 'Resets the value to 0.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | examples => ["\$obj->$reset_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 2 | my @inc_methods = uniq "inc_${field}", "${field}_inc"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 2 | for my $name (@inc_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=16.8
Subroutine
inc_an_integer: called CC=3 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition16%1/6
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | $_[0]->{$field}++; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 2 | name => \@inc_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | purpose => 'Increases the value by 1.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | examples => ["\$obj->$inc_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 2 | my @dec_methods = uniq "dec_${field}", "${field}_dec"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 2 | for my $name (@dec_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | 2 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | 2 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | 2 | $_[0]->{$field}--; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 2 | name => \@dec_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | purpose => 'Decreases the value by 1.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | examples => ["\$obj->$dec_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 1 | ▶ | sub mk_set_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_set_accessors: called CC=10 SCAR=26.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 1 | my ($self, @fields) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | 1 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 1 | my $insert_method = "${field}_insert"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 1 | my $elements_method = "${field}_elements"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | 2 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 2 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 2 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 1 | $self->$insert_method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 1 | $self->$elements_method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | 1 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | A set is like an array except that each element can occur only one. It is, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | however, not ordered. If called with a list of arguments, it adds those | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | elements to the set. If the first argument is an array reference, the values | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | contained therein are added to the set. If called without arguments, it | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | returns the elements of the set. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | "my \@elements = \$obj->$field;", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | "\$obj->$field(\@elements);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 1 | my @insert_methods = uniq "insert_${field}", $insert_method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | 1 | for my $name (@insert_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 0 | $self->{$field}{$_}++ for flatten(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 1 | name => \@insert_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | If called with a list of arguments, it adds those elements to the set. If the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | first argument is an array reference, the values contained therein are added | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | to the set. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | examples => ["\$obj->$insert_methods[0](\@elements);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | 1 | my @elements_methods = uniq "elements_${field}", $elements_method; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | 1 | for my $name (@elements_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 0 | ▶ | $self->{$field} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{$field} ||= {}
MC/DC0%0/1
$self->{$field} ||= {}
$self->{$field}
Truth table0%0/2
A
A= $self->{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 0 | keys %{ $self->{$field} }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 1 | name => \@elements_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | purpose => 'Returns the elements of the set.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | examples => ["my \@elements = \$obj->$elements_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 1 | my @delete_methods = uniq "delete_${field}", "${field}_delete"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 1 | for my $name (@delete_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | 1 | delete $self->{$field}{$_} for @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 1 | name => \@delete_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | If called with a list of values, it deletes those elements from the set. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | examples => ["\$obj->$delete_methods[0](\@elements);"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | 1 | my @clear_methods = uniq "clear_${field}", "${field}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 1 | for my $name (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 1 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 1 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 1 | $_[0]->{$field} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 1 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | purpose => 'Deletes all elements from the set.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | examples => ["\$obj->$clear_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 1 | my @contains_methods = uniq "contains_${field}", "${field}_contains"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 1 | for my $name (@contains_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 4 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | 4 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | 4 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 4 | ▶ | return unless defined $key; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 4 | exists $self->{$field}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | 1 | name => \@contains_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | purpose => <<'EODOC', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | Takes a single key and returns a boolean value indicating whether that key is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | an element of the set. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | examples => ["if (\$obj->$contains_methods[0](\$element)) { ... }"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | , | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | 1 | my @is_empty_methods = uniq "is_empty_${field}", "${field}_is_empty"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | 1 | for my $name (@is_empty_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | 2 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | 2 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | 2 | ▶ | keys %{ $self->{$field} || {} } == 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{$field} || {}
MC/DC0%0/1
$self->{$field} || {}
$self->{$field}
Truth table50%1/2
A
A= $self->{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | 1 | name => \@is_empty_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | purpose => | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | 'Returns a boolean value indicating whether the set is empty of not.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | examples => ["\$obj->$is_empty_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | 1 | my @size_methods = uniq "size_${field}", "${field}_size"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | 1 | for my $name (@size_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | 4 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=15.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | 4 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | 4 | ▶ | scalar keys %{ $self->{$field} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{$field} || {}
MC/DC0%0/1
$self->{$field} || {}
$self->{$field}
Truth table50%1/2
A
A= $self->{$field}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | 1 | name => \@size_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | purpose => 'Returns the number of elements in the set.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | examples => ["my \$size = \$obj->$size_methods[0];"], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | belongs_to => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | 2 | ▶ | sub mk_object_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_object_accessors: called CC=11 SCAR=29.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | 2 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | 2 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | 2 | ▶ | while (@args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | 3 | my $type = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | 3 | ▶ | my $list = shift @args or die "No slot names for $class"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | # Allow a list of hashrefs. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | 3 | ▶ | my @list = ref($list) eq 'ARRAY' ? @$list : ($list); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | 3 | for my $obj_def (@list) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | 3 | my ($name, @composites); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | 3 | ▶ | if (!ref $obj_def) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | 2 | $name = $obj_def; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | 1 | $name = $obj_def->{slot}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | 1 | my $composites = $obj_def->{comp_mthds}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | 1 | ▶ | @composites = | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | ref($composites) eq 'ARRAY' ? @$composites | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | : defined $composites ? ($composites) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | : (); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | 3 | for my $meth (@composites) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | name => $meth, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::{$meth}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | 0 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | 0 | $self->$name()->$meth(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | 2 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | 2 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | name => $meth, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | purpose => <<EODOC, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | Calls $meth() with the given arguments on the object stored in the $name slot. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | If there is no such object, a new $type object is constructed - no arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | are passed to the constructor - and stored in the $name slot before forwarding | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | $meth() onto it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | examples => [ "\$obj->$meth(\@args);", "\$obj->$meth;", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | 9 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | 9 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${name}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | 9 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | 9 | ▶ | if (ref($args[0]) && UNIVERSAL::isa($args[0], $type)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $args[0] and UNIVERSAL::isa($args[0], $type)
MC/DC0%0/2
ref $args[0] and UNIVERSAL::isa($args[0], $type)
ref $args[0]
UNIVERSAL::isa($args[0], $type)
Truth table33%1/3
A and B
A= ref $args[0]B= UNIVERSAL::isa($args[0], $type)
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | 0 | $self->{$name} = $args[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | defined $self->{$name} | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | 9 | ▶ | or $self->{$name} = $type->new(@args); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | 9 | $self->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | 3 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | purpose => <<EODOC, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | If called with an argument object of type $type it sets the object; further | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | arguments are discarded. If called with arguments but the first argument is | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | not an object of type $type, a new object of type $type is constructed and the | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | arguments are passed to the constructor. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | If called without arguments, it returns the $type object stored in this slot; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | if there is no such object, a new $type object is constructed - no arguments | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | are passed to the constructor in this case - and stored in the $name slot | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | before returning it. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | examples => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | "my \$object = \$obj->$name;", "\$obj->$name(\$object);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | "\$obj->$name(\@args);", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | 3 | my @clear_methods = uniq "clear_${name}", "${name}_clear"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | 3 | for my $meth (@clear_methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | name => $meth, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | 0 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | 0 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${meth}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table0%0/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | 0 | delete $_[0]->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | 6 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | $self->document_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | 3 | name => \@clear_methods, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | purpose => 'Deletes the object.', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | examples => "\$obj->$clear_methods[0];", | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | belongs_to => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | 2 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | 1 | ▶ | sub mk_forward_accessors { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mk_forward_accessors: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | 1 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | 1 | ▶ | my $class = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | 1 | ▶ | while (my ($slot, $methods) = each %args) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | 2 | ▶ | my @methods = ref $methods eq 'ARRAY' ? @$methods : ($methods); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | 2 | for my $field (@methods) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | $self->install_accessor( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | 3 | ▶ | code => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | 3 | ▶ | local $DB::sub = local *__ANON__ = "${class}::${field}" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined &DB::DB and not $Devel::DProf::VERSION
MC/DC0%0/2
defined &DB::DB and not $Devel::DProf::VERSION
defined &DB::DB
not $Devel::DProf::VERSION
Truth table33%1/3
A and not(B)
A= defined &DB::DBB= not $Devel::DProf::VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | if defined &DB::DB && !$Devel::DProf::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | 3 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | 3 | $self->$slot()->$field(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | 3 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | 3 | $self->document_accessor( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | name => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | purpose => <<EODOC, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | Calls $field() with the given arguments on the object stored in the $slot | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | slot. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | EODOC | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | examples => [ "\$obj->$field(\@args);", "\$obj->$field;", ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | 1 | $self; # for chaining | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | 13 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||