| 1 | package blx::xsdsql::ut::common_interfaces; | ||||||||||||||
| 2 | 1 | ▶ | use strict; # use strict is for PBP | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 1 | ▶ | use Filter::Include; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | include blx::xsdsql::include; | ||||||||||||||
| 5 | #line 6 | ||||||||||||||
| 6 | 1 | ▶ | use Storable; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 0 | ▶ | sub _fusion_params { | ||||||||||||
|
Subroutine
_fusion_params: not called CC=2 SCAR=7.2
| |||||||||||||||
| 9 | 0 | my ($self,%params)=@_; | |||||||||||||
| 10 | 0 | ▶ | my %p=%$self; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||
| 11 | 0 | ▶ | for my $p(keys %params) { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||
| 12 | 0 | ▶ | $p{$p}=$params{$p}; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||
| 13 | 1 | ▶ | } | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | 0 | ▶ | return \%p; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||
| 15 | 1 | ▶ | } | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 1 | ▶ | |||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | 1 | ▶ | sub _get_attrs_w { | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
_get_attrs_w: not called CC=1 SCAR=0.1
| |||||||||||||||
| 18 | 0 | croak "set the method _get_attrs_w for use set_attrs_value\n"; | |||||||||||||
| 19 | 0 | ▶ | return $_[0]; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
| |||||||||||||||
| 20 | } | ||||||||||||||
| 21 | |||||||||||||||
| 22 | 0 | ▶ | sub _get_attrs_r { | ||||||||||||
|
Subroutine
_get_attrs_r: not called CC=1 SCAR=6.9
| |||||||||||||||
| 23 | 0 | croak "set the metod _get_attrs_r for use get_attrs_value\n"; | |||||||||||||
| 24 | 0 | return $_[0]; | |||||||||||||
| 25 | } | ||||||||||||||
| 26 | |||||||||||||||
| 27 | 0 | ▶ | sub _am { | ||||||||||||
|
Subroutine
_am: not called CC=1 SCAR=6.9
| |||||||||||||||
| 28 | 0 | croak "abstract method called\n"; | |||||||||||||
| 29 | 0 | return $_[0]; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | |||||||||||||||
| 32 | 0 | ▶ | sub get_attrs_value { | ||||||||||||
|
Subroutine
get_attrs_value: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||
| 33 | 0 | my $self=shift; | |||||||||||||
| 34 | 0 | my $h=$self->_get_attrs_r; | |||||||||||||
| 35 | 0 | my @out=(); | |||||||||||||
| 36 | 0 | for my $attr(@_) { | |||||||||||||
| 37 | 0 | ▶ | my $f=exists $h->{$attr} ? $h->{$attr} : undef; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | 0 | ▶ | if (!defined $f) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 39 | 0 | push @out,$self->{$attr}; | |||||||||||||
| 40 | } | ||||||||||||||
| 41 | elsif (ref($f) eq 'CODE') { | ||||||||||||||
| 42 | 0 | push @out,$f->($self,$attr); | |||||||||||||
| 43 | } | ||||||||||||||
| 44 | else { | ||||||||||||||
| 45 | 0 | push @out,$f; | |||||||||||||
| 46 | } | ||||||||||||||
| 47 | } | ||||||||||||||
| 48 | 0 | ▶ | return @out if wantarray; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 49 | 0 | ▶ | return \@out if scalar(@out) > 1; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 50 | 0 | ▶ | return $out[0] if scalar(@out) == 1; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 51 | 0 | undef; | |||||||||||||
| 52 | } | ||||||||||||||
| 53 | |||||||||||||||
| 54 | 0 | ▶ | sub set_attrs_value { | ||||||||||||
|
Subroutine
set_attrs_value: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||
| 55 | 0 | my $self=shift; | |||||||||||||
| 56 | 0 | ▶ | affirm { scalar(@_) % 2 == 0 } "Odd elements"; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 57 | 0 | my $h=$self->_get_attrs_w; | |||||||||||||
| 58 | 0 | ▶ | for (my $i=0; $i < scalar(@_); $i+=2) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 59 | 0 | my ($attr,$v)=($_[$i],$_[$i + 1]); | |||||||||||||
| 60 | 0 | ▶ | my $f=exists $h->{$attr} ? $h->{$attr} : undef; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 61 | 0 | ▶ | if (!defined $f) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 62 | 0 | $self->{$attr}=$v; | |||||||||||||
| 63 | } | ||||||||||||||
| 64 | else { | ||||||||||||||
| 65 | 0 | ▶ | affirm { ref($f) eq 'CODE' } "the handler must be a CODE"; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 66 | 0 | $self->{$attr}=$f->($self,$v); | |||||||||||||
| 67 | } | ||||||||||||||
| 68 | } | ||||||||||||||
| 69 | 0 | return $self; | |||||||||||||
| 70 | } | ||||||||||||||
| 71 | |||||||||||||||
| 72 | 0 | ▶ | sub shallow_clone { | ||||||||||||
|
Subroutine
shallow_clone: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 73 | 0 | my ($self,%params)=@_; | |||||||||||||
| 74 | 0 | my %newtable=%$self; | |||||||||||||
| 75 | 0 | return bless \%newtable,ref($self); | |||||||||||||
| 76 | } | ||||||||||||||
| 77 | |||||||||||||||
| 78 | 0 | ▶ | sub get_clone { | ||||||||||||
|
Subroutine
get_clone: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||
| 79 | 0 | my ($self,%params)=@_; | |||||||||||||
| 80 | 0 | return Storable::dclone($self); | |||||||||||||
| 81 | } | ||||||||||||||
| 82 | |||||||||||||||
| 83 | |||||||||||||||
| 84 | 0 | ▶ | sub _clone_from_attributes { | ||||||||||||
|
Subroutine
_clone_from_attributes: not called CC=1 SCAR=6.9
| |||||||||||||||
| 85 | 0 | my ($self,$k,%params)=@_; | |||||||||||||
| 86 | 0 | ▶ | affirm { ref($k) eq 'ARRAY' } "1^ param must be ARRAY"; | ||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||
| 87 | 0 | my $values=$self->get_attrs_value(@$k); | |||||||||||||
| 88 | 0 | my %attrs=map { ($k->[$_],$values->[$_]) } (0..scalar(@$k) - 1); | |||||||||||||
| 89 | 0 | return bless \%attrs,ref($self); | |||||||||||||
| 90 | } | ||||||||||||||
| 91 | |||||||||||||||
| 92 | |||||||||||||||
| 93 | 1 | 1; | |||||||||||||
| 94 | |||||||||||||||
| 95 | __END__ | ||||||||||||||