DBIx/Class/CDBICompat/AccessorMapping.pm

filter: Statementstmt 20.0% 7 / 35 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 33.3% 2 / 6 Podpod 0.0% 0 / 4 totaltotal 12.6% 9 / 71 CC 13 SCAR 34.5
CC
13
Cov
12%
mk_group_accessors
56.0
new
30.0
accessor_name_for
6.0
CRAP 31.6
« DBIx/Class/Storage/DBIHacks.pm ↑ Summary DBIx/Class/CDBICompat/Constraints.pm »
1 package # hide from PAUSE Indexer
2 DBIx::Class::CDBICompat::AccessorMapping;
3  
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 sub mk_group_accessors {
8 0 ▶ my ($class, $group, @cols) = @_;
Subroutine mk_group_accessors: not called CC=7 SCAR=40.3
Pod undocumented
9  
10 0 foreach my $col (@cols) {
11 0 ▶ my($accessor, $col) = ref $col ? @$col : (undef, $col);
Branch: 1 branch
BranchTrueFalseTotal
ref $col ? : 0 0 0
12  
13 0 my($ro_meth, $wo_meth);
14 0 ▶ if( defined $accessor and ($accessor ne $col)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $accessor and $accessor ne $col) { } 0 0 0
Condition0%0/3
defined $accessor and $accessor ne $col
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
15 0 $ro_meth = $wo_meth = $accessor;
16 }
17 else {
18 0 $ro_meth = $class->accessor_name_for($col);
19 0 $wo_meth = $class->mutator_name_for($col);
20 }
21  
22 # warn "class: $class / col: $col / ro: $ro_meth / wo: $wo_meth\n";
23 0 ▶ if ($ro_meth eq $wo_meth or # they're the same
Branch: 1 branch
BranchTrueFalseTotal
if ($ro_meth eq $wo_meth or $wo_meth eq $col) { } 0 0 0
Condition0%0/3
$ro_meth eq $wo_meth or $wo_meth eq $col
l!l&&r!l&&!r
000
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
ABresult
1X1
011
000
24 $wo_meth eq $col) # or only the accessor is custom
25 {
26 0 $class->next::method($group => [ $ro_meth => $col ]);
27 }
28 else {
29 0 $class->mk_group_ro_accessors($group => [ $ro_meth => $col ]);
30 0 $class->mk_group_wo_accessors($group => [ $wo_meth => $col ]);
31 }
32 }
33 }
34  
35  
36 sub accessor_name_for {
37 0 ▶ my ($class, $column) = @_;
Subroutine accessor_name_for: not called CC=2 SCAR=17.9
Pod undocumented
38 0 ▶ if ($class->can('accessor_name')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->can("accessor_name")) 0 0 0
39 0 return $class->accessor_name($column)
40 }
41  
42 0 return $column;
43 }
44  
45 sub mutator_name_for {
46 0 ▶ my ($class, $column) = @_;
Subroutine mutator_name_for: not called CC=2 SCAR=17.9
Pod undocumented
47 0 ▶ if ($class->can('mutator_name')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class->can("mutator_name")) 0 0 0
48 0 return $class->mutator_name($column)
49 }
50  
51 0 return $column;
52 }
53  
54  
55 sub new {
56 0 ▶ my ($class, $attrs, @rest) = @_;
Subroutine new: not called CC=5 SCAR=34.0
Pod undocumented
57 0 ▶ $class->throw_exception( "create needs a hashref" ) unless ref $attrs eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attrs eq "HASH" 0 0 0
58 0 foreach my $col ($class->columns) {
59 0 my $acc = $class->accessor_name_for($col);
60 0 ▶ $attrs->{$col} = delete $attrs->{$acc} if exists $attrs->{$acc};
Branch: 1 branch
BranchTrueFalseTotal
if exists $attrs->{$acc} 0 0 0
61  
62 0 my $mut = $class->mutator_name_for($col);
63 0 ▶ $attrs->{$col} = delete $attrs->{$mut} if exists $attrs->{$mut};
Branch: 1 branch
BranchTrueFalseTotal
if exists $attrs->{$mut} 0 0 0
64 }
65 0 return $class->next::method($attrs, @rest);
66 }
67  
68 1 1;
« DBIx/Class/Storage/DBIHacks.pm ↑ Summary DBIx/Class/CDBICompat/Constraints.pm »