blib/lib/DBIx/Class/Relationship/Predicate.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 87.5% 7 / 8 Conditioncond 100% 5 / 5 MC/DCmcdc 100% 3 / 3 Subroutinesub 83.3% 10 / 12 Podpod 0.0% 0 / 2 totaltotal 90.1% 64 / 71 CC 7 SCAR 8.6
CC
7
Cov
94%
add_relationship_predicate
4.0
register_relationship
4.0
__ANON__
1.1
CRAP 2.4
↑ Summary
1 package DBIx::Class::Relationship::Predicate;
2  
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use parent 'DBIx::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Sub::Name ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 our $VERSION = '0.07'; # VERSION
9  
10 # ABSTRACT: Predicates for relationship accessors
11  
12  
13 5 ▶sub register_relationship {
Subroutine register_relationship: called CC=4 SCAR=13.9
Pod undocumented
14 5 my ($class, $rel, $info) = @_;
15 5 my $attrs = $info->{'attrs'};
16 5 ▶ if (my $acc_type = $attrs->{'accessor'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $acc_type = $attrs->{"accessor"}) 4 1 5
17 4 ▶ if ( defined($attrs->{'predicate'}) || !exists($attrs->{'predicate'}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attrs->{"predicate"} or not exists $attrs->{"predicate"}) 3 1 4
Condition100%3/3
defined $attrs->{"predicate"} or not exists $attrs->{"predicate"}
l!l&&r!l&&!r
121
MC/DC100%2/2
defined $attrs->{"predicate"} or not exists $attrs->{"predicate"}
defined $attrs->{"predicate"} not exists $attrs->{"predicate"}
Truth table100%3/3
A or not(B)
A= defined $attrs->{"predicate"}B= not exists $attrs->{"predicate"}
ABresult
1X1
011
000
18 $class->add_relationship_predicate(
19 3 $rel, $acc_type, $attrs->{'predicate'}
20 );
21 }
22 }
23 5 $class->next::method($rel, $info);
24 }
25  
26 3 ▶sub add_relationship_predicate {
Subroutine add_relationship_predicate: called CC=4 SCAR=13.9
Pod undocumented
27 3 my ( $class, $relname, $accessor_type, $predicate ) = @_;
28 3 ▶ $predicate ||= "has_${relname}";
Condition100%2/2
$predicate ||= "has_$relname"
l!l
12
MC/DC100%1/1
$predicate ||= "has_$relname"
$predicate
Truth table100%2/2
A
A= $predicate
Aresult
11
00
29 3 my $name = join '::', $class, $predicate;
30  
31 3 my $predicate_meth;
32 3 ▶ if ( $accessor_type =~ m{single|filter}i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($accessor_type =~ /single|filter/i) { } 2 1 3
elsif ($accessor_type eq 'multi') { } 1 0 1
33 0 ▶ $predicate_meth = Sub::Name::subname($name, sub {
Subroutine __ANON__: not called CC=1 SCAR=1.2
Subroutine got_a_buzz: called CC=1 SCAR=1.2
34 0 return defined(shift->$relname);
35 2 });
36 } elsif ( $accessor_type eq 'multi' ) {
37 0 ▶ $predicate_meth = Sub::Name::subname($name, sub {
Subroutine __ANON__: not called CC=1 SCAR=1.2
Subroutine has_bars: called CC=1 SCAR=1.2
38 0 return shift->$relname->count;
39 1 });
40 }
41  
42 {
43 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
44 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
45 3 *$name = $predicate_meth;
46 }
47 }
48  
49  
50 1 1;
51  
52 __END__
↑ Summary