| 1 | # | ||||||||||||||||||||||||||||
| 2 | # This file is part of Config-Model | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # This software is Copyright (c) 2005-2022 by Dominique Dumont. | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # This is free software, licensed under: | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # The GNU Lesser General Public License, Version 2.1, February 1999 | ||||||||||||||||||||||||||||
| 9 | # | ||||||||||||||||||||||||||||
| 10 | package Config::Model::Role::WarpSubject 2.169; | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | # ABSTRACT: common methods for a warped element | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 59 | ▶ | use Mouse::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 59 | ▶ | use Mouse::Util; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 59 | ▶ | use feature qw/postderef signatures/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 59 | ▶ | no warnings qw/experimental::postderef experimental::signatures/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 59 | requires 'backup', 'allowed_warp_params'; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 59 | ▶ | use Log::Log4perl qw(get_logger :levels); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 59 | my $logger = get_logger("WarpSubject"); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 5632 | ▶ | sub merge_properties($self, %raw_args) { | ||||||||||||||||||||||||||
|
Subroutine
merge_properties: called CC=8 SCAR=20.9
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 5632 | ▶ | my %args = %{ $self->backup // {} }; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->backup // {}
MC/DC0%0/1
$self->backup // {}
$self->backup
Truth table50%1/2
A
A= $self->backup
| |||||||||||||||||||||||||||||
| 28 | 5632 | for my $p ( $self->allowed_warp_params() ) { | |||||||||||||||||||||||||||
| 29 | # cleanup all parameters that are handled by warp | ||||||||||||||||||||||||||||
| 30 | 106795 | delete $self->{$p}; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 106795 | ▶ | next unless exists $raw_args{$p}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 439 | my $new = $raw_args{$p}; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 439 | ▶ | if (defined $args{$p} and ref $args{$p} eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $args{$p} and ref $args{$p} eq "HASH"
MC/DC100%2/2
defined $args{$p} and ref $args{$p} eq "HASH"
defined $args{$p}
ref $args{$p} eq "HASH"
Truth table100%3/3
A and B
A= defined $args{$p}B= ref $args{$p} eq "HASH"
| |||||||||||||||||||||||||||||
| 37 | 23 | ▶ | if (ref $new eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 23 | for my $sub_p (keys $new->%*) { | |||||||||||||||||||||||||||
| 39 | 23 | $args{$p}{$sub_p} = $new->{$sub_p}; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||
| 43 | 0 | Config::Model::Exception::Model->throw( | |||||||||||||||||||||||||||
| 44 | object => $self, | ||||||||||||||||||||||||||||
| 45 | error => "property $p is not a HASH ref" | ||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | else { | ||||||||||||||||||||||||||||
| 50 | 416 | $args{$p} = $new; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 5632 | return %args; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 59 | 1; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||||||||