| 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
| |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | if ( defined($attrs->{'predicate'}) || !exists($attrs->{'predicate'}) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $attrs->{"predicate"} or not exists $attrs->{"predicate"}
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"}
| |||||||||||||||||||||||||||||
| 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"
MC/DC100%1/1
$predicate ||= "has_$relname"
$predicate
Truth table100%2/2
A
A= $predicate
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||