| 1 | 404 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::ObjectUtil; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 404 | $HTML::FormFu::ObjectUtil::VERSION = '2.06'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | 404 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 404 | ▶ | use Exporter qw( import ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 404 | use HTML::FormFu::Util qw( | |||||||||||||||||||||||||||||||||||||||||
| 10 | _parse_args require_class | ||||||||||||||||||||||||||||||||||||||||||
| 11 | _get_elements | ||||||||||||||||||||||||||||||||||||||||||
| 12 | _filter_components _merge_hashes | ||||||||||||||||||||||||||||||||||||||||||
| 13 | 404 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 404 | ▶ | use Clone (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 404 | ▶ | use Config::Any; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 404 | ▶ | use Data::Visitor::Callback; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 404 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 404 | ▶ | use Scalar::Util qw( refaddr weaken blessed ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 404 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 404 | our @EXPORT_OK = ( qw( | |||||||||||||||||||||||||||||||||||||||||
| 22 | deflator | ||||||||||||||||||||||||||||||||||||||||||
| 23 | load_config_file load_config_filestem | ||||||||||||||||||||||||||||||||||||||||||
| 24 | form | ||||||||||||||||||||||||||||||||||||||||||
| 25 | get_parent | ||||||||||||||||||||||||||||||||||||||||||
| 26 | insert_before insert_after | ||||||||||||||||||||||||||||||||||||||||||
| 27 | clone | ||||||||||||||||||||||||||||||||||||||||||
| 28 | name | ||||||||||||||||||||||||||||||||||||||||||
| 29 | stash | ||||||||||||||||||||||||||||||||||||||||||
| 30 | parent | ||||||||||||||||||||||||||||||||||||||||||
| 31 | nested_name nested_names | ||||||||||||||||||||||||||||||||||||||||||
| 32 | remove_element | ||||||||||||||||||||||||||||||||||||||||||
| 33 | _string_equals _object_equals | ||||||||||||||||||||||||||||||||||||||||||
| 34 | _load_file | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ), | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | sub load_config_file { | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 141 | ▶ | my ( $self, @files ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 141 | my $use_stems = 0; | |||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 141 | return _load_config( $self, $use_stems, @files ); | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | sub load_config_filestem { | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | ▶ | my ( $self, @files ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_config_filestem: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | 1 | my $use_stems = 1; | |||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | return _load_config( $self, $use_stems, @files ); | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub _load_config { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 142 | ▶ | my ( $self, $use_stems, @filenames ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_config: called CC=14 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | 142 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 1 | @filenames = @{ $filenames[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 142 | my $config_callback = $self->config_callback; | |||||||||||||||||||||||||||||||||||||||||
| 62 | 142 | my $data_visitor; | |||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 142 | ▶ | if ( defined $config_callback ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | $data_visitor = Data::Visitor::Callback->new( %$config_callback, | |||||||||||||||||||||||||||||||||||||||||
| 66 | ignore_return_values => 1, ); | ||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 142 | ▶ | my $config_any_arg = $use_stems ? 'stems' : 'files'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 142 | ▶ | my $config_any_method = $use_stems ? 'load_stems' : 'load_files'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | 142 | my @config_file_path; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 142 | ▶ | if ( my $config_file_path = $self->config_file_path ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | ▶ | if ( ref $config_file_path eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | push @config_file_path, @$config_file_path; | |||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||
| 79 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | push @config_file_path, $config_file_path; | |||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||
| 83 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 138 | push @config_file_path, File::Spec->curdir; | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 142 | for my $file (@filenames) { | |||||||||||||||||||||||||||||||||||||||||
| 88 | 143 | my $loaded = 0; | |||||||||||||||||||||||||||||||||||||||||
| 89 | 143 | my $fullpath; | |||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 143 | foreach my $config_file_path (@config_file_path) { | |||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||
| 93 | 150 | ▶ | 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)
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | && !File::Spec->file_name_is_absolute($file) ) | ||||||||||||||||||||||||||||||||||||||||||
| 95 | { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 150 | $fullpath = File::Spec->catfile( $config_file_path, $file ); | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $fullpath = $file; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 150 | my $config = Config::Any->$config_any_method( | |||||||||||||||||||||||||||||||||||||||||
| 103 | { $config_any_arg => [$fullpath], | ||||||||||||||||||||||||||||||||||||||||||
| 104 | use_ext => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | driver_args => { General => { -UTF8 => 1 }, }, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } ); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 150 | ▶ | next if !@$config; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 142 | $loaded = 1; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 142 | my ( $filename, $filedata ) = %{ $config->[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 142 | _load_file( $self, $data_visitor, $filedata ); | |||||||||||||||||||||||||||||||||||||||||
| 114 | 142 | last; | |||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 143 | ▶ | croak "config file '$file' not found" if !$loaded; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 141 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | sub _load_file { | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 142 | ▶ | my ( $self, $data_visitor, $data ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_file: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 142 | ▶ | if ( defined $data_visitor ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | $data_visitor->visit($data); | |||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 142 | ▶ | for my $config ( ref $data eq 'ARRAY' ? @$data : $data ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 143 | $self->populate( Clone::clone($config) ); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | 142 | return; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | sub form { | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 29206 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
form: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | # micro optimization! this method's called a lot, so access | ||||||||||||||||||||||||||||||||||||||||||
| 140 | # parent hashkey directly, instead of calling parent() | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 29206 | ▶ | while ( defined( my $parent = $self->{parent} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 50382 | $self = $parent; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 29206 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | sub clone { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 2 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 2 | my %new = %$self; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | 2 | $new{_elements} = [ map { $_->clone } @{ $self->_elements } ]; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 2 | $new{attributes} = Clone::clone( $self->attributes ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 2 | $new{tt_args} = Clone::clone( $self->tt_args ); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | $new{model_config} = Clone::clone( $self->model_config ); | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 2 | ▶ | if ( $self->can('_plugins') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 2 | $new{_plugins} = [ map { $_->clone } @{ $self->_plugins } ]; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | $new{languages} | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 | ▶ | = ref $self->languages | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | ? Clone::clone( $self->languages ) | ||||||||||||||||||||||||||||||||||||||||||
| 165 | : $self->languages; | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | $new{default_args} = $self->default_args; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | my $obj = bless \%new, ref $self; | |||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 2 | map { $_->parent($obj) } @{ $new{_elements} }; | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | return $obj; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | sub name { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 111 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | 111 | ▶ | croak 'cannot use name() as a setter' if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 111 | return $self->parent->name; | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | sub nested_name { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 1111 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nested_name: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 1111 | ▶ | croak 'cannot use nested_name() as a setter' if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 1111 | return $self->parent->nested_name; | |||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | sub nested_names { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nested_names: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | croak 'cannot use nested_names() as a setter' if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return $self->parent->nested_names; | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | sub stash { | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 5125 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stash: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 5125 | ▶ | $self->{stash} = {} if not exists $self->{stash}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 5125 | ▶ | return $self->{stash} if !@_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 3303 | ▶ | my %attrs = ( @_ == 1 ) ? %{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 3303 | $self->{stash}->{$_} = $attrs{$_} for keys %attrs; | |||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 3303 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | sub parent { | ||||||||||||||||||||||||||||||||||||||||||
| 214 | 16339 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parent: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | 16339 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 2456 | $self->{parent} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 2456 | weaken( $self->{parent} ); | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 2456 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | 13883 | return $self->{parent}; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | sub get_parent { | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 70 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_parent: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 70 | ▶ | return $self->parent | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | if !@_; | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | 69 | my %args = _parse_args(@_); | |||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | 69 | ▶ | while ( defined( my $parent = $self->parent ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 140 | for my $name ( keys %args ) { | |||||||||||||||||||||||||||||||||||||||||
| 238 | 140 | my $value; | |||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 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}
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | && defined( $value = $parent->$name ) | ||||||||||||||||||||||||||||||||||||||||||
| 242 | && $value eq $args{$name} ) | ||||||||||||||||||||||||||||||||||||||||||
| 243 | { | ||||||||||||||||||||||||||||||||||||||||||
| 244 | 67 | return $parent; | |||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 73 | $self = $parent; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | sub _string_equals { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | my ( $a, $b ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_string_equals: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | return blessed($b) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | ? ( refaddr($a) eq refaddr($b) ) | ||||||||||||||||||||||||||||||||||||||||||
| 259 | : ( "$a" eq "$b" ); | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | sub _object_equals { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | my ( $a, $b ) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_object_equals: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | return blessed($b) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | ? ( refaddr($a) eq refaddr($b) ) | ||||||||||||||||||||||||||||||||||||||||||
| 267 | : undef; | ||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 404 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | __END__ | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | HTML::FormFu::ObjectUtil | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | version 2.06 | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | Carl Franks <cpan@fireartist.com> | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | This software is copyright (c) 2018 by Carl Franks. | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||
| 295 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | =cut | ||||||||||||||||||||||||||||||||||||||||||