| 1 | package # hide from PAUSE Indexer | ||||||||||||||||||||||||||||||||
| 2 | DBIx::Class::CDBICompat::AccessorMapping; | ||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Scalar::Util 'blessed'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | sub mk_group_accessors { | ||||||||||||||||||||||||||||||
|
Subroutine
mk_group_accessors: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 11 | 0 | my ($class, $group, @cols) = @_; | |||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 0 | foreach my $col (@cols) { | |||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | my($accessor, $col) = ref $col eq 'ARRAY' ? @$col : (undef, $col); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | 0 | my($ro_meth, $wo_meth); | |||||||||||||||||||||||||||||||
| 17 | 0 | ▶ | if (defined blessed $col and $col->isa('Class::DBI::Column')) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined builtin::blessed($col) and $col->isa("Class::DBI::Column")
MC/DC0%0/2
defined builtin::blessed($col) and $col->isa("Class::DBI::Column")
defined builtin::blessed($col)
$col->isa("Class::DBI::Column")
Truth table0%0/3
A and B
A= defined builtin::blessed($col)B= $col->isa("Class::DBI::Column")
| |||||||||||||||||||||||||||||||||
| 18 | 0 | $ro_meth = $col->accessor; | |||||||||||||||||||||||||||||||
| 19 | 0 | $wo_meth = $col->mutator; | |||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||
| 21 | ▶ | elsif (defined $accessor and ($accessor ne $col)) { | |||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $accessor and $accessor ne $col
MC/DC0%0/2
defined $accessor and $accessor ne $col
defined $accessor
$accessor ne $col
Truth table0%0/3
A and B
A= defined $accessorB= $accessor ne $col
| |||||||||||||||||||||||||||||||||
| 22 | 0 | $ro_meth = $wo_meth = $accessor; | |||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||
| 24 | else { | ||||||||||||||||||||||||||||||||
| 25 | 0 | $ro_meth = $class->accessor_name_for($col); | |||||||||||||||||||||||||||||||
| 26 | 0 | $wo_meth = $class->mutator_name_for($col); | |||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||
| 29 | # warn "class: $class / col: $col / ro: $ro_meth / wo: $wo_meth\n"; | ||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | if ($ro_meth eq $wo_meth or # they're the same | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ro_meth eq $wo_meth or $wo_meth eq $col
MC/DC0%0/2
$ro_meth eq $wo_meth or $wo_meth eq $col
$ro_meth eq $wo_meth
$wo_meth eq $col
Truth table0%0/3
A or B
A= $ro_meth eq $wo_methB= $wo_meth eq $col
| |||||||||||||||||||||||||||||||||
| 31 | $wo_meth eq $col) # or only the accessor is custom | ||||||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||||||
| 33 | 0 | $class->next::method($group => [ $ro_meth => $col ]); | |||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||
| 35 | else { | ||||||||||||||||||||||||||||||||
| 36 | 0 | $class->mk_group_ro_accessors($group => [ $ro_meth => $col ]); | |||||||||||||||||||||||||||||||
| 37 | 0 | $class->mk_group_wo_accessors($group => [ $wo_meth => $col ]); | |||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub accessor_name_for { | ||||||||||||||||||||||||||||||
|
Subroutine
accessor_name_for: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 44 | 0 | my ($class, $column) = @_; | |||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | if ($class->can('accessor_name')) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 46 | 0 | return $class->accessor_name($column) | |||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 0 | return $column; | |||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 0 | ▶ | sub mutator_name_for { | ||||||||||||||||||||||||||||||
|
Subroutine
mutator_name_for: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 53 | 0 | my ($class, $column) = @_; | |||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if ($class->can('mutator_name')) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 55 | 0 | return $class->mutator_name($column) | |||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 0 | return $column; | |||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 63 | 0 | my ($class, $attrs, @rest) = @_; | |||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | $class->throw_exception( "create needs a hashref" ) unless ref $attrs eq 'HASH'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 65 | 0 | foreach my $col ($class->columns) { | |||||||||||||||||||||||||||||||
| 66 | 0 | my $acc = $class->accessor_name_for($col); | |||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | $attrs->{$col} = delete $attrs->{$acc} if exists $attrs->{$acc}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 0 | my $mut = $class->mutator_name_for($col); | |||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | $attrs->{$col} = delete $attrs->{$mut} if exists $attrs->{$mut}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||
| 72 | 0 | return $class->next::method($attrs, @rest); | |||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 2 | 1; | |||||||||||||||||||||||||||||||