| 1 | package Alzabo::ForeignKey; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 11 | ▶ | use vars qw($VERSION); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 11 | ▶ | use Alzabo; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 11 | $VERSION = 2.0; | |||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 11 | 1; | |||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | sub table_from | ||||||||||||||||||||
| 14 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
table_from: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 15 | 0 | my $self = shift; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 0 | return ($self->columns_from)[0]->table; | |||||||||||||||||||
| 18 | } | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | sub table_to | ||||||||||||||||||||
| 21 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
table_to: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 22 | 0 | my $self = shift; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | return ($self->columns_to)[0]->table; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | sub columns_from | ||||||||||||||||||||
| 28 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
columns_from: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 29 | 0 | my $self = shift; | |||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | ▶ | return wantarray ? @{ $self->{columns_from} } : $self->{columns_from}[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | } | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | sub columns_to | ||||||||||||||||||||
| 35 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
columns_to: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 36 | 0 | my $self = shift; | |||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | return wantarray ? @{ $self->{columns_to} } : $self->{columns_to}[0]; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | sub column_pairs | ||||||||||||||||||||
| 42 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
column_pairs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 43 | 0 | my $self = shift; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | return ( map { [ $self->{columns_from}[$_] => $self->{columns_to}[$_] ] } | |||||||||||||||||||
| 46 | 0 | 0..$#{ $self->{columns_from} } ); | |||||||||||||||||||
| 47 | } | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | sub column_pair_names | ||||||||||||||||||||
| 50 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
column_pair_names: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 51 | 0 | my $self = shift; | |||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | return ( map { [ $self->{columns_from}[$_]->name => $self->{columns_to}[$_]->name ] } | |||||||||||||||||||
| 54 | 0 | 0..$#{ $self->{columns_from} } ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | sub cardinality | ||||||||||||||||||||
| 58 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
cardinality: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 59 | 0 | my $self = shift; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 0 | return @{ $self->{cardinality} }; | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | sub is_one_to_one | ||||||||||||||||||||
| 65 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
is_one_to_one: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 66 | 0 | my $self = shift; | |||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | my @c = $self->cardinality; | |||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 0 | ▶ | return $c[0] eq '1' && $c[1] eq '1'; | ||||||||||||||||||
|
Condition0%0/3
$c[0] eq '1' && $c[1] eq '1'
MC/DC0%0/2
$c[0] eq '1' && $c[1] eq '1'
$c[0] eq '1'
$c[1] eq '1'
Truth table0%0/3
A && B
A= $c[0] eq '1'B= $c[1] eq '1'
| |||||||||||||||||||||
| 71 | } | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | sub is_one_to_many | ||||||||||||||||||||
| 74 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
is_one_to_many: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 75 | 0 | my $self = shift; | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | my @c = $self->cardinality; | |||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | ▶ | return $c[0] eq '1' && $c[1] eq 'n'; | ||||||||||||||||||
|
Condition0%0/3
$c[0] eq '1' && $c[1] eq 'n'
MC/DC0%0/2
$c[0] eq '1' && $c[1] eq 'n'
$c[0] eq '1'
$c[1] eq 'n'
Truth table0%0/3
A && B
A= $c[0] eq '1'B= $c[1] eq 'n'
| |||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | sub is_many_to_one | ||||||||||||||||||||
| 83 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
is_many_to_one: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 84 | 0 | my $self = shift; | |||||||||||||||||||
| 85 | |||||||||||||||||||||
| 86 | 0 | my @c = $self->cardinality; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | 0 | ▶ | return $c[0] eq 'n' && $c[1] eq '1'; | ||||||||||||||||||
|
Condition0%0/3
$c[0] eq 'n' && $c[1] eq '1'
MC/DC0%0/2
$c[0] eq 'n' && $c[1] eq '1'
$c[0] eq 'n'
$c[1] eq '1'
Truth table0%0/3
A && B
A= $c[0] eq 'n'B= $c[1] eq '1'
| |||||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | sub from_is_dependent | ||||||||||||||||||||
| 92 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
from_is_dependent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 93 | 0 | return shift->{from_is_dependent}; | |||||||||||||||||||
| 94 | } | ||||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | sub to_is_dependent | ||||||||||||||||||||
| 97 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
to_is_dependent: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 98 | 0 | return shift->{to_is_dependent}; | |||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | sub is_same_relationship_as | ||||||||||||||||||||
| 102 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
is_same_relationship_as: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 103 | 0 | my ($self, $other) = @_; | |||||||||||||||||||
| 104 | 0 | ▶ | return ( $self->id eq $other->id | ||||||||||||||||||
|
Condition0%0/3
$self->id eq $other->id || $self->id eq $other->reverse->id
MC/DC0%0/2
$self->id eq $other->id || $self->id eq $other->reverse->id
$self->id eq $other->id
$self->id eq $other->reverse->id
Truth table0%0/3
A || B
A= $self->id eq $other->idB= $self->id eq $other->reverse->id
| |||||||||||||||||||||
| 105 | or | ||||||||||||||||||||
| 106 | $self->id eq $other->reverse->id | ||||||||||||||||||||
| 107 | ); | ||||||||||||||||||||
| 108 | } | ||||||||||||||||||||
| 109 | |||||||||||||||||||||
| 110 | sub reverse | ||||||||||||||||||||
| 111 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
reverse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 112 | 0 | my $self = shift; | |||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | return bless { table_from => $self->table_to, | ||||||||||||||||||||
| 115 | table_to => $self->table_from, | ||||||||||||||||||||
| 116 | columns_from => [ $self->columns_to ], | ||||||||||||||||||||
| 117 | columns_to => [ $self->columns_from ], | ||||||||||||||||||||
| 118 | from_is_dependent => $self->to_is_dependent, | ||||||||||||||||||||
| 119 | to_is_dependent => $self->from_is_dependent, | ||||||||||||||||||||
| 120 | 0 | cardinality => [ reverse @{ $self->{cardinality} } ], | |||||||||||||||||||
| 121 | }, ref $self; | ||||||||||||||||||||
| 122 | } | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | sub id | ||||||||||||||||||||
| 125 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 126 | 0 | my $self = shift; | |||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | 0 | return join '___', ( ( map { $_->name } | |||||||||||||||||||
| 129 | $self->table_from, | ||||||||||||||||||||
| 130 | $self->table_to, | ||||||||||||||||||||
| 131 | $self->columns_from, | ||||||||||||||||||||
| 132 | $self->columns_to, | ||||||||||||||||||||
| 133 | ), | ||||||||||||||||||||
| 134 | $self->cardinality, | ||||||||||||||||||||
| 135 | $self->from_is_dependent, | ||||||||||||||||||||
| 136 | $self->to_is_dependent, | ||||||||||||||||||||
| 137 | ); | ||||||||||||||||||||
| 138 | } | ||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | 0 | ▶ | sub comment { $_[0]->{comment} } | ||||||||||||||||||
|
Subroutine
comment: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | __END__ | ||||||||||||||||||||