« lib/HTML/FormFu/Role/Element/SingleValueField.pm
↑ Summary
lib/HTML/FormFu/Deflator/CompoundDateTime.pm »
| 1 | 525 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::ObjectUtil; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # ABSTRACT: utilities for dealing with FormFu objects | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 525 | $HTML::FormFu::ObjectUtil::VERSION = '2.09'; | |||||||||||||||||||||||||||||||||||||||||
| 6 | 525 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 525 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 525 | ▶ | use HTML::FormFu::Util qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | _parse_args require_class | ||||||||||||||||||||||||||||||||||||||||||
| 12 | _get_elements | ||||||||||||||||||||||||||||||||||||||||||
| 13 | _filter_components _merge_hashes | ||||||||||||||||||||||||||||||||||||||||||
| 14 | 525 | ); | |||||||||||||||||||||||||||||||||||||||||
| 15 | 525 | ▶ | use Clone (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 525 | ▶ | use Config::Any; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 525 | ▶ | use Data::Visitor::Callback; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 525 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 525 | ▶ | use Scalar::Util qw( refaddr weaken blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 525 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 525 | our @EXPORT_OK = ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 23 | deflator | ||||||||||||||||||||||||||||||||||||||||||
| 24 | load_config_file load_config_filestem | ||||||||||||||||||||||||||||||||||||||||||
| 25 | form | ||||||||||||||||||||||||||||||||||||||||||
| 26 | get_parent | ||||||||||||||||||||||||||||||||||||||||||
| 27 | insert_before insert_after | ||||||||||||||||||||||||||||||||||||||||||
| 28 | clone | ||||||||||||||||||||||||||||||||||||||||||
| 29 | name | ||||||||||||||||||||||||||||||||||||||||||
| 30 | stash | ||||||||||||||||||||||||||||||||||||||||||
| 31 | parent | ||||||||||||||||||||||||||||||||||||||||||
| 32 | nested_name nested_names | ||||||||||||||||||||||||||||||||||||||||||
| 33 | remove_element | ||||||||||||||||||||||||||||||||||||||||||
| 34 | _string_equals _object_equals | ||||||||||||||||||||||||||||||||||||||||||
| 35 | _load_file | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | 153 | ▶ | sub load_config_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 153 | my ( $self, @files ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 153 | my $use_stems = 0; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 153 | return _load_config( $self, $use_stems, @files ); | |||||||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | sub load_config_filestem { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config_filestem: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 1 | my ( $self, @files ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | my $use_stems = 1; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | return _load_config( $self, $use_stems, @files ); | |||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | 154 | ▶ | sub _load_config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_config: called CC=14 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 154 | my ( $self, $use_stems, @filenames ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 154 | ▶ | if ( scalar @filenames == 1 && ref $filenames[0] eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
scalar @filenames == 1 and ref $filenames[0] eq "ARRAY"
MC/DC50%1/2
scalar @filenames == 1 and ref $filenames[0] eq "ARRAY"
scalar @filenames == 1
ref $filenames[0] eq "ARRAY"
Truth table66%2/3
A and B
A= scalar @filenames == 1B= ref $filenames[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | @filenames = @{ $filenames[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 154 | my $config_callback = $self->config_callback; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 154 | my $data_visitor; | |||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 154 | ▶ | if ( defined $config_callback ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | $data_visitor = Data::Visitor::Callback->new( %$config_callback, | |||||||||||||||||||||||||||||||||||||||||
| 67 | ignore_return_values => 1, ); | ||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | 154 | ▶ | my $config_any_arg = $use_stems ? 'stems' : 'files'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 154 | ▶ | my $config_any_method = $use_stems ? 'load_stems' : 'load_files'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | 154 | my @config_file_path; | |||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | 154 | ▶ | if ( my $config_file_path = $self->config_file_path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | if ( ref $config_file_path eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | push @config_file_path, @$config_file_path; | |||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | push @config_file_path, $config_file_path; | |||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 150 | push @config_file_path, File::Spec->curdir; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | 154 | for my $file (@filenames) { | |||||||||||||||||||||||||||||||||||||||||
| 89 | 155 | my $loaded = 0; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 155 | my $fullpath; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 155 | foreach my $config_file_path (@config_file_path) { | |||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 162 | ▶ | if ( defined $config_file_path | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $config_file_path and not "File::Spec"->file_name_is_absolute($file)
MC/DC0%0/2
defined $config_file_path and not "File::Spec"->file_name_is_absolute($file)
defined $config_file_path
not "File::Spec"->file_name_is_absolute($file)
Truth table33%1/3
A and not(B)
A= defined $config_file_pathB= not "File::Spec"->file_name_is_absolute($file)
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | && !File::Spec->file_name_is_absolute($file) ) | ||||||||||||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 162 | $fullpath = File::Spec->catfile( $config_file_path, $file ); | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $fullpath = $file; | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 162 | my $config = Config::Any->$config_any_method( | |||||||||||||||||||||||||||||||||||||||||
| 104 | { $config_any_arg => [$fullpath], | ||||||||||||||||||||||||||||||||||||||||||
| 105 | use_ext => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | driver_args => { General => { -UTF8 => 1 }, }, | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 162 | ▶ | next if !@$config; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 154 | $loaded = 1; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 154 | my ( $filename, $filedata ) = %{ $config->[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 154 | _load_file( $self, $data_visitor, $filedata ); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 154 | last; | |||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 155 | ▶ | croak "config file '$file' not found" if !$loaded; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 153 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 154 | ▶ | sub _load_file { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_file: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 154 | my ( $self, $data_visitor, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 154 | ▶ | if ( defined $data_visitor ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | $data_visitor->visit($data); | |||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 154 | ▶ | for my $config ( ref $data eq 'ARRAY' ? @$data : $data ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 155 | $self->populate( Clone::clone($config) ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 154 | return; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 33770 | ▶ | sub form { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 33770 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # micro optimization! this method's called a lot, so access | ||||||||||||||||||||||||||||||||||||||||||
| 141 | # parent hashkey directly, instead of calling parent() | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 33770 | ▶ | while ( defined( my $parent = $self->{parent} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 58109 | $self = $parent; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 33770 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 2 | my %new = %$self; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | $new{_elements} = [ map { $_->clone } @{ $self->_elements } ]; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | $new{attributes} = Clone::clone( $self->attributes ); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | $new{tt_args} = Clone::clone( $self->tt_args ); | |||||||||||||||||||||||||||||||||||||||||
| 157 | 2 | $new{model_config} = Clone::clone( $self->model_config ); | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | ▶ | if ( $self->can('_plugins') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | $new{_plugins} = [ map { $_->clone } @{ $self->_plugins } ]; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | $new{languages} | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | ▶ | = ref $self->languages | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | ? Clone::clone( $self->languages ) | ||||||||||||||||||||||||||||||||||||||||||
| 166 | : $self->languages; | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 2 | $new{default_args} = $self->default_args; | |||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | my $obj = bless \%new, ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 2 | map { $_->parent($obj) } @{ $new{_elements} }; | |||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 2 | return $obj; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 111 | ▶ | sub name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 111 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 111 | ▶ | croak 'cannot use name() as a setter' if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||
| 182 | 111 | return $self->parent->name; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 1231 | ▶ | sub nested_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nested_name: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 1231 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 1231 | ▶ | croak 'cannot use nested_name() as a setter' if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | 1231 | return $self->parent->nested_name; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub nested_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nested_names: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | croak 'cannot use nested_names() as a setter' if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return $self->parent->nested_names; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 5979 | ▶ | sub stash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stash: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 5979 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 5979 | ▶ | $self->{stash} = {} if not exists $self->{stash}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 5979 | ▶ | return $self->{stash} if !@_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | 4140 | ▶ | my %attrs = ( @_ == 1 ) ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 4140 | $self->{stash}->{$_} = $attrs{$_} for keys %attrs; | |||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 4140 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | 17614 | ▶ | sub parent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 17614 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 17614 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 3277 | $self->{parent} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | 3277 | weaken( $self->{parent} ); | |||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | 3277 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 14337 | return $self->{parent}; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 70 | ▶ | sub get_parent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_parent: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 70 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | 70 | ▶ | return $self->parent | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | if !@_; | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 69 | my %args = _parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 69 | ▶ | while ( defined( my $parent = $self->parent ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 140 | for my $name ( keys %args ) { | |||||||||||||||||||||||||||||||||||||||||
| 239 | 140 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 140 | ▶ | if ( $parent->can($name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$parent->can($name) and defined($value = $parent->$name) and $value eq $args{$name}
$parent->can($name) and defined($value = $parent->$name)
MC/DC66%2/3
$parent->can($name) and defined($value = $parent->$name) and $value eq $args{$name}
$parent->can($name)
defined($value = $parent->$name)
$value eq $args{$name}
Truth table75%3/4
A and B and C
A= $parent->can($name)B= defined($value = $parent->$name)C= $value eq $args{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | && defined( $value = $parent->$name ) | ||||||||||||||||||||||||||||||||||||||||||
| 243 | && $value eq $args{$name} ) | ||||||||||||||||||||||||||||||||||||||||||
| 244 | { | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 67 | return $parent; | |||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 73 | $self = $parent; | |||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub _string_equals { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_string_equals: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my ( $a, $b ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | return blessed($b) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | ? ( refaddr($a) eq refaddr($b) ) | ||||||||||||||||||||||||||||||||||||||||||
| 260 | : ( "$a" eq "$b" ); | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | sub _object_equals { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object_equals: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my ( $a, $b ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | return blessed($b) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | ? ( refaddr($a) eq refaddr($b) ) | ||||||||||||||||||||||||||||||||||||||||||
| 268 | : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 525 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | __END__ | ||||||||||||||||||||||||||||||||||||||||||