blib/lib/DBIO/Extension/Protocol.pm

filter: Statementstmt 99.0% 203 / 205 Branchbran 91.1% 82 / 90 Conditioncond 56.6% 34 / 60 MC/DCmcdc 23.3% 7 / 30 Subroutinesub 96.0% 24 / 25 Podpod 100% 14 / 14 totaltotal 85.8% 364 / 424 CC 82 SCAR 25.5
CC
82
Cov
90%
activation
28.9
verdict
15.1
annotate
12.1
CRAP 12.8
« blib/lib/DBIO/Relationship/ManyToMany.pm ↑ Summary blib/lib/DBIO/Admin.pm »
1 package DBIO::Extension::Protocol;
2 # ABSTRACT: Runs the phases of the extension interface over the active extensions and merges their answers
3  
4 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 9 our $VERSION = '0.900007';
8  
9 9 ▶use DBIO::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 9 ▶use DBIO::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 125 ▶sub new {
Subroutine new: called CC=7 SCAR=19.9
Pod documented
14 125 my ($class, %args) = @_;
15 125 ▶ my %entry = map { $_->{name} => $_ } @{ $args{entries} || [] };
Condition50%1/2
$args{'entries'} || []
l!l
1250
MC/DC0%0/1
$args{'entries'} || []
$args{'entries'}
Truth table50%1/2
A
A= $args{'entries'}
Aresult
11
00
16 125 my @names = sort keys %entry;
17  
18 125 my @run = @names;
19 125 ▶ if (my $order = $args{run_order}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $order = $args{"run_order"}) 51 74 125
20 51 my %known = map { $_ => 1 } @names;
21 DBIO::Exception->throw('Extension protocol: run_order must name exactly the active extensions')
22 51 ▶ unless @$order == @names && !grep { !$known{$_} } @$order;
Branch: 1 branch
BranchTrueFalseTotal
unless @$order == @names and not grep({not $known{$_};} @$order) 0 51 51
Condition33%1/3
@$order == @names and not grep({not $known{$_};} @$order)
!ll&&!rl&&r
0051
MC/DC0%0/2
@$order == @names and not grep({not $known{$_};} @$order)
@$order == @names not grep({not $known{$_};} @$order)
Truth table33%1/3
A and not(B)
A= @$order == @namesB= not grep({not $known{$_};} @$order)
ABresult
0X0
100
111
23 51 @run = @$order;
24 }
25  
26 return bless {
27 entry => \%entry,
28 names => \@names,
29 run => \@run,
30 driver => $args{driver} || {},
31 connection => $args{connection_schema},
32 restricted => $args{restricted} ? 1 : 0,
33 verify_input => $args{verify_input},
34 trace_on => $args{trace},
35 125 ▶ state => {},
Branch: 1 branch
BranchTrueFalseTotal
$args{'restricted'} ? : 1 124 125
Condition50%1/2
$args{'driver'} || {}
l!l
1250
MC/DC0%0/1
$args{'driver'} || {}
$args{'driver'}
Truth table50%1/2
A
A= $args{'driver'}
Aresult
11
00
36 trace => {},
37 refusals => [],
38 conflicts => [],
39 models => undef,
40 }, $class;
41 }
42  
43  
44 0 ▶sub names { @{ $_[0]{names} } }
Subroutine names: not called CC=1 SCAR=6.9
Pod documented
45  
46  
47 38 ▶sub trace { DBIO::Util::deep_copy($_[0]{trace}) }
Subroutine trace: called CC=1 SCAR=0.0
Pod documented
48  
49  
50 66 ▶sub states { DBIO::Util::deep_copy($_[0]{state}) }
Subroutine states: called CC=1 SCAR=0.0
Pod documented
51  
52  
53 51 ▶sub models {
Subroutine models: called CC=1 SCAR=0.0
Pod documented
54 51 my ($self, %models) = @_;
55 51 $self->{models} = { source => $models{source}, target => $models{target} };
56 51 return $self;
57 }
58  
59 # --- internals ---------------------------------------------------------------
60  
61 3816 ▶sub _clone { ref $_[0] ? DBIO::Util::deep_copy($_[0]) : $_[0] }
Subroutine _clone: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 2647 1169 3816
62  
63 1397 ▶sub _entry_view {
Subroutine _entry_view: called CC=4 SCAR=13.9
64 1397 my ($self, $entry, $with_options) = @_;
65 my $view = {
66 class => $entry->{class},
67 installed => $entry->{installed} ? 1 : 0,
68 version => $entry->{version},
69 schema => $entry->{schema},
70 1397 ▶ state => _clone($self->{state}{ $entry->{name} }),
Branch: 1 branch
BranchTrueFalseTotal
$entry->{'installed'} ? : 1270 127 1397
71 };
72 1397 ▶ if ($with_options) {
Branch: 1 branch
BranchTrueFalseTotal
if ($with_options) 738 659 1397
73 738 $view->{name} = $entry->{name};
74 738 ▶ $view->{options} = _clone($entry->{options} || {});
Condition50%1/2
$entry->{'options'} || {}
l!l
7380
MC/DC0%0/1
$entry->{'options'} || {}
$entry->{'options'}
Truth table50%1/2
A
A= $entry->{'options'}
Aresult
11
00
75 }
76 1397 return $view;
77 }
78  
79 738 ▶sub _ctx {
Subroutine _ctx: called CC=1 SCAR=0.0
80 738 my ($self, $entry, %extra) = @_;
81 return {
82 659 peers => { map { $_ => $self->_entry_view($self->{entry}{$_}) }
83 1397 grep { $_ ne $entry->{name} } @{ $self->{names} } },
84 self => $self->_entry_view($entry, 1),
85 driver => $self->{driver},
86 connection_schema => $self->{connection},
87 restricted => $self->{restricted},
88 738 %extra,
89 };
90 }
91  
92 # One call of one extension. @input is copied; the answer is returned as is.
93 738 ▶sub _call {
Subroutine _call: called CC=7 SCAR=19.5
94 738 my ($self, $name, $method, $input, %ctx_extra) = @_;
95 738 my $entry = $self->{entry}{$name};
96 738 my $class = $entry->{class};
97  
98 738 my @args = map { _clone($_) } @$input;
99 738 my $ctx = $self->_ctx($entry, %ctx_extra);
100 738 ▶ my @before = $self->{verify_input} ? (map { DBIO::Util::canonical_text($_) } @args, _ctx_data($ctx)) : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'verify_input'} ? : 583 155 738
101  
102 738 my $answer = $class->$method(@args, $ctx);
103  
104 738 ▶ if ($self->{verify_input}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"verify_input"}) 583 155 738
105 583 for my $i (0 .. $#args) {
106 433 ▶ DBIO::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if DBIO::Util::canonical_text($args[$i]) ne $before[$i] 19 414 433
107 "Extension '$name' changed its input in $method (extensions must not modify their arguments)"
108 ) if DBIO::Util::canonical_text($args[$i]) ne $before[$i];
109 }
110 DBIO::Exception->throw(
111 564 ▶ "Extension '$name' changed its context in $method (extensions must not modify their arguments)"
Branch: 1 branch
BranchTrueFalseTotal
if DBIO::Util::canonical_text(_ctx_data($ctx)) ne $before[-1] 6 558 564
112 ) if DBIO::Util::canonical_text(_ctx_data($ctx)) ne $before[-1];
113 }
114 713 ▶ push @{ $self->{trace}{$name}{$method} }, _clone($answer) if $self->{trace_on};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"trace_on"} 554 159 713
115 713 return $answer;
116 }
117  
118 # The data part of a context: everything but the driver helpers and the handle.
119 1147 ▶sub _ctx_data { my ($ctx) = @_; return { map { $_ => $ctx->{$_} } grep { $_ ne 'driver' && $_ ne 'dbh' } keys %$ctx } }
Subroutine _ctx_data: called CC=2 SCAR=6.9
Condition100%3/3
$_ ne 'driver' && $_ ne 'dbh'
!ll&&!rl&&r
11471804812
MC/DC100%2/2
$_ ne 'driver' && $_ ne 'dbh'
$_ ne 'driver' $_ ne 'dbh'
Truth table100%3/3
A && B
A= $_ ne 'driver'B= $_ ne 'dbh'
ABresult
0X0
100
111
120  
121 293 ▶sub _address_key { DBIO::Util::canonical_text($_[0]) }
Subroutine _address_key: called CC=1 SCAR=0.0
122  
123 286 ▶sub _check_address {
Subroutine _check_address: called CC=5 SCAR=20.2
124 286 my ($name, $method, $address) = @_;
125 DBIO::Exception->throw("Extension '$name': $method must return addresses (array references of scalars)")
126 286 ▶ unless ref $address eq 'ARRAY' && @$address && !grep { !defined $_ || ref $_ } @$address;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $address eq "ARRAY" and @$address and not grep({not defined $_ or ref $_;} @$address) 0 286 286
Condition33%3/9
ref $address eq "ARRAY" and @$address and not grep({not defined $_ or ref $_;} @$address)
!ll&&!rl&&r
00286
ref $address eq "ARRAY" and @$address
!ll&&!rl&&r
00286
!defined($_) || ref $_
l!l&&r!l&&!r
00772
MC/DC0%0/3
ref $address eq "ARRAY" and @$address and not grep({not defined $_ or ref $_;} @$address)
ref $address eq "ARRAY" @$address not grep({not defined $_ or ref $_;} @$address)
MC/DC0%0/2
!defined($_) || ref $_
!defined($_) ref $_
Truth table25%1/4
A and B and not(C)
A= ref $address eq "ARRAY"B= @$addressC= not grep({not defined $_ or ref $_;} @$address)
ABCresult
0XX0
10X0
1100
1111
Truth table33%1/3
not(A) || B
A= !defined($_)B= ref $_
ABresult
1X1
011
000
127 286 return;
128 }
129  
130 # --- phase 0 ---------------------------------------------------------------------
131  
132  
133 66 ▶sub inspect {
Subroutine inspect: called CC=3 SCAR=11.0
Pod documented
134 66 my ($self, $dbh) = @_;
135 66 $self->{state} = {};
136 66 my %state;
137 66 for my $name (@{ $self->{run} }) {
138 106 my $answer = $self->_call($name, 'inspect', [], dbh => $dbh);
139 106 ▶ $state{$name} = $answer if defined $answer;
Branch: 1 branch
BranchTrueFalseTotal
if defined $answer 40 66 106
140 }
141 66 $self->{state} = { map { $_ => _clone($state{$_}) } keys %state };
142 66 return $self->states;
143 }
144  
145 # --- phase 1 ---------------------------------------------------------------------
146  
147  
148 145 ▶sub claims {
Subroutine claims: called CC=4 SCAR=13.9
Pod documented
149 145 my ($self, $model) = @_;
150 145 my %address;
151 145 for my $name (@{ $self->{run} }) {
152 223 my $answer = $self->_call($name, 'claims', [$model]);
153 198 ▶ DBIO::Exception->throw("Extension '$name': claims must return an array reference of addresses")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $answer eq "ARRAY" 1 197 198
154 unless ref $answer eq 'ARRAY';
155 197 for my $address (@$answer) {
156 86 _check_address($name, 'claims', $address);
157 86 $address{ _address_key($address) } = _clone($address);
158 }
159 }
160 119 return [ map { $address{$_} } sort keys %address ];
161 }
162  
163 # --- phase 2 ---------------------------------------------------------------------
164  
165  
166 111 ▶sub annotate {
Subroutine annotate: called CC=12 SCAR=24.9
Pod documented
167 111 my ($self, $model) = @_;
168 111 my %by;
169 111 for my $name (@{ $self->{run} }) {
170 181 my $answer = $self->_call($name, 'annotate', [$model]);
171 181 ▶ DBIO::Exception->throw("Extension '$name': annotate must return an array reference of triples")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $answer eq "ARRAY" 0 181 181
172 unless ref $answer eq 'ARRAY';
173 181 for my $triple (@$answer) {
174 201 ▶ DBIO::Exception->throw("Extension '$name': annotate must return [ \$address, \$attribute, \$value ] triples")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $triple eq "ARRAY" and @$triple == 3 and defined $triple->[1] and not ref $triple->[1] 1 200 201
Condition66%6/9
ref $triple eq "ARRAY" and @$triple == 3 and defined $triple->[1] and not ref $triple->[1]
!ll&&!rl&&r
10200
ref $triple eq "ARRAY" and @$triple == 3 and defined $triple->[1]
!ll&&!rl&&r
10200
ref $triple eq "ARRAY" and @$triple == 3
!ll&&!rl&&r
01200
MC/DC25%1/4
ref $triple eq "ARRAY" and @$triple == 3 and defined $triple->[1] and not ref $triple->[1]
ref $triple eq "ARRAY" @$triple == 3 defined $triple->[1] not ref $triple->[1]
Truth table40%2/5
A and B and C and not(D)
A= ref $triple eq "ARRAY"B= @$triple == 3C= defined $triple->[1]D= not ref $triple->[1]
ABCDresult
0XXX0
10XX0
110X0
11100
11111
175 unless ref $triple eq 'ARRAY' && @$triple == 3 && defined $triple->[1] && !ref $triple->[1];
176 200 _check_address($name, 'annotate', $triple->[0]);
177 200 my $key = _address_key($triple->[0]) . "\0" . $triple->[1];
178 200 push @{ $by{$key} }, { name => $name, triple => _clone($triple), frozen => DBIO::Util::canonical_text($triple->[2]) };
179 }
180 }
181  
182 110 my (@merged, @conflicts);
183 110 for my $key (sort keys %by) {
184 192 my %values;
185 192 push @{ $values{ $_->{frozen} } }, $_ for @{ $by{$key} };
186 192 ▶ if (keys %values > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %values > 1) 7 185 192
187 7 my ($address, $attribute) = ($by{$key}[0]{triple}[0], $by{$key}[0]{triple}[1]);
188 my @parts = sort map {
189 7 my @who = sort map { $_->{name} } @{ $values{$_} };
190 14 join(', ', @who) . ' => ' . DBIO::Util::canonical_text($values{$_}[0]{triple}[2])
191 } keys %values;
192 7 push @conflicts, _address_key($address) . ".$attribute: " . join('; ', @parts);
193 7 next;
194 }
195 185 push @merged, $by{$key}[0]{triple};
196 }
197 DBIO::Exception->throw(
198 110 ▶ "Extensions annotate the same object differently:\n " . join("\n ", @conflicts)
Branch: 1 branch
BranchTrueFalseTotal
if @conflicts 7 103 110
199 ) if @conflicts;
200 103 return \@merged;
201 }
202  
203 # --- phase 3 ---------------------------------------------------------------------
204  
205  
206 83 ▶sub verdict {
Subroutine verdict: called CC=15 SCAR=27.1
Pod documented
207 83 my ($self, $change) = @_;
208 83 ▶ my %ask = $self->{models} ? (models => _clone($self->{models})) : ();
Branch: 1 branch
BranchTrueFalseTotal
$self->{'models'} ? : 73 10 83
209  
210 83 my (%using, %refuse);
211 83 for my $name (@{ $self->{run} }) {
212 146 my $answer = $self->_call($name, 'verdict', [$change], %ask);
213 146 ▶ next unless defined $answer;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $answer 65 81 146
214 81 ▶ my ($kind, @extra) = ref $answer eq 'HASH' ? sort keys %$answer : ();
Branch: 1 branch
BranchTrueFalseTotal
ref $answer eq 'HASH' ? : 80 1 81
215 DBIO::Exception->throw(
216 "Extension '$name': verdict must return undef, { using => \$expr } or { refuse => \$message }"
217 ) unless defined $kind && !@extra && ($kind eq 'using' || $kind eq 'refuse')
218 81 ▶ && defined $answer->{$kind} && !ref $answer->{$kind};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $kind and not @extra and $kind eq "using" || $kind eq "refuse" and defined $answer->{$kind} and not ref $answer->{$kind} 2 79 81
Condition73%11/15
defined $kind and not @extra and $kind eq "using" || $kind eq "refuse" and defined $answer->{$kind} and not ref $answer->{$kind}
!ll&&!rl&&r
2079
defined $kind and not @extra and $kind eq "using" || $kind eq "refuse" and defined $answer->{$kind}
!ll&&!rl&&r
2079
defined $kind and not @extra and $kind eq "using" || $kind eq "refuse"
!ll&&!rl&&r
2079
defined $kind and not @extra
!ll&&!rl&&r
1179
$kind eq "using" or $kind eq "refuse"
l!l&&r!l&&!r
67120
MC/DC33%2/6
defined $kind and not @extra and $kind eq "using" || $kind eq "refuse" and defined $answer->{$kind} and not ref $answer->{$kind}
defined $kind not @extra $kind eq "using" $kind eq "refuse" defined $answer->{$kind} not ref $answer->{$kind}
Truth table44%4/9
A and not(B) and C or D and E and not(F)
A= defined $kindB= not @extraC= $kind eq "using"D= $kind eq "refuse"E= defined $answer->{$kind}F= not ref $answer->{$kind}
ABCDEFresult
0XXXXX0
10XXXX0
1100XX0
111X0X0
11010X0
111X100
1101100
111X111
1101111
219 79 ▶ ($kind eq 'using' ? \%using : \%refuse)->{$name} = $answer->{$kind};
Branch: 1 branch
BranchTrueFalseTotal
$kind eq 'using' ? : 67 12 79
220 }
221  
222 81 ▶ if (%refuse) {
Branch: 1 branch
BranchTrueFalseTotal
if (%refuse) 10 71 81
223 10 my @messages = map { "$_: $refuse{$_}" } sort keys %refuse;
224 10 push @{ $self->{refusals} }, @messages;
225 10 return { refuse => \@messages };
226 }
227 71 ▶ return undef unless %using;
Branch: 1 branch
BranchTrueFalseTotal
unless %using 18 53 71
228  
229 53 my %distinct = map { $_ => 1 } values %using;
230 53 ▶ if (keys %distinct > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (keys %distinct > 1) 10 43 53
231 my $message = 'conflicting answers: '
232 10 . join('; ', map { "$_: $using{$_}" } sort keys %using);
233 10 push @{ $self->{conflicts} }, $message;
234 10 push @{ $self->{refusals} }, $message;
235 10 return { refuse => [$message] };
236 }
237 43 return { using => (values %using)[0] };
238 }
239  
240  
241 44 ▶sub refusals { @{ $_[0]{refusals} } }
Subroutine refusals: called CC=1 SCAR=0.0
Pod documented
242  
243  
244 44 ▶sub conflicts { @{ $_[0]{conflicts} } }
Subroutine conflicts: called CC=1 SCAR=0.0
Pod documented
245  
246  
247 4 ▶sub assert_no_refusals {
Subroutine assert_no_refusals: called CC=2 SCAR=6.9
Pod documented
248 4 my ($self) = @_;
249 4 ▶ return 1 unless @{ $self->{refusals} };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->{"refusals"};} 2 2 4
250 DBIO::Exception->throw(
251 2 "The diff is refused by its extensions:\n - " . join("\n - ", @{ $self->{refusals} })
252 );
253 }
254  
255 # --- activation --------------------------------------------------------------------------
256  
257  
258 53 ▶sub activation {
Subroutine activation: called CC=26 SCAR=33.6
Pod documented
259 53 my ($self) = @_;
260 53 my %answer;
261 53 for my $name (@{ $self->{run} }) {
262 82 my $answer = $self->_call($name, 'activation', []);
263 82 ▶ next unless defined $answer;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $answer 40 42 82
264 42 ▶ DBIO::Exception->throw("Extension '$name': activation must return a hash reference (data, not statements)")
Branch: 1 branch
BranchTrueFalseTotal
unless ref $answer eq "HASH" 0 42 42
265 unless ref $answer eq 'HASH';
266 42 ▶ my @unknown = grep { $_ ne 'load' && $_ ne 'search_path' } sort keys %$answer;
Condition100%3/3
$_ ne 'load' && $_ ne 'search_path'
!ll&&!rl&&r
37351
MC/DC100%2/2
$_ ne 'load' && $_ ne 'search_path'
$_ ne 'load' $_ ne 'search_path'
Truth table100%3/3
A && B
A= $_ ne 'load'B= $_ ne 'search_path'
ABresult
0X0
100
111
267 42 ▶ DBIO::Exception->throw("Extension '$name': activation has unknown key(s) " . join(', ', @unknown)
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 1 41 42
268 . " (only load and search_path)") if @unknown;
269 41 $answer{$name} = $answer;
270 }
271  
272 52 my (%library, %owner, @load, @path, %seen_path);
273 52 for my $name (@{ $self->{names} }) {
274 81 ▶ my $answer = $answer{$name} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $answer = $answer{$name} or next 41 40 81
275  
276 41 my $load = $answer->{load};
277 my @pairs = !defined $load ? ()
278 2 ▶ : ref $load eq 'HASH' ? map { [ $_, $load->{$_} ] } sort keys %$load
Branch: 1 branch
BranchTrueFalseTotal
ref $load eq 'ARRAY' ? : 8 27 35
279 41 ▶ : ref $load eq 'ARRAY' ? map { [ $_, $_ ] } @$load
Branch: 3 branches
BranchTrueFalseTotal
!defined($load) ? : 4 37 41
ref $load eq 'HASH' ? : 2 35 37
!ref($load) ? : 27 0 27
280 : !ref $load ? ([ $load, $load ])
281 : DBIO::Exception->throw("Extension '$name': activation load must be a name, a list or a hash");
282 41 for my $pair (@pairs) {
283 40 my ($lname, $lib) = @$pair;
284 40 ▶ DBIO::Exception->throw("Extension '$name': activation load names an empty or compound value")
Branch: 1 branch
BranchTrueFalseTotal
unless defined $lname and not ref $lname and defined $lib and not ref $lib 0 40 40
Condition33%3/9
defined $lname and not ref $lname and defined $lib and not ref $lib
!ll&&!rl&&r
0040
defined $lname and not ref $lname and defined $lib
!ll&&!rl&&r
0040
defined $lname and not ref $lname
!ll&&!rl&&r
0040
MC/DC0%0/4
defined $lname and not ref $lname and defined $lib and not ref $lib
defined $lname not ref $lname defined $lib not ref $lib
Truth table20%1/5
A and not(B) and C and not(D)
A= defined $lnameB= not ref $lnameC= defined $libD= not ref $lib
ABCDresult
0XXX0
10XX0
110X0
11100
11111
285 unless defined $lname && !ref $lname && defined $lib && !ref $lib;
286 40 DBIO::Util::assert_identifier_text("Extension '$name': activation load", $_) for $lname, $lib;
287 36 ▶ if (exists $library{$lname}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $library{$lname}) 4 32 36
288 DBIO::Exception->throw(
289 "Activation cannot compose: '$lname' is loaded from '$library{$lname}' by "
290 . "$owner{$lname} and from '$lib' by $name"
291 4 ▶ ) if $library{$lname} ne $lib;
Branch: 1 branch
BranchTrueFalseTotal
if $library{$lname} ne $lib 1 3 4
292 3 next;
293 }
294 32 $library{$lname} = $lib;
295 32 $owner{$lname} = $name;
296 32 push @load, $lib;
297 }
298  
299 36 my $path = $answer->{search_path};
300 36 ▶ for my $schema (!defined $path ? () : ref $path eq 'ARRAY' ? @$path : ($path)) {
Branch: 2 branches
BranchTrueFalseTotal
!defined($path) ? : 1 35 36
ref $path eq 'ARRAY' ? : 35 0 35
301 39 ▶ DBIO::Exception->throw("Extension '$name': activation search_path must hold schema names")
Branch: 1 branch
BranchTrueFalseTotal
if not defined $schema or ref $schema 0 39 39
Condition33%1/3
not defined $schema or ref $schema
l!l&&r!l&&!r
0039
MC/DC0%0/2
not defined $schema or ref $schema
not defined $schema ref $schema
Truth table33%1/3
not(A) or B
A= not defined $schemaB= ref $schema
ABresult
1X1
011
000
302 if !defined $schema || ref $schema;
303 39 DBIO::Util::assert_identifier_text("Extension '$name': activation search_path", $schema);
304 35 ▶ push @path, $schema unless $seen_path{$schema}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $seen_path{$schema}++ 32 3 35
305 }
306 }
307 43 return { load => \@load, search_path => \@path };
308 }
309  
310 # --- running phases 1 and 2 on a pair of models ----------------------------------------------
311  
312  
313 65 ▶sub extend_models {
Subroutine extend_models: called CC=5 SCAR=16.1
Pod documented
314 65 my ($self, $deploy, @models) = @_;
315 65 my $states = $self->{state};
316 65 for my $model (@models) {
317 116 $model = _clone($model);
318 116 my $claims = $self->claims($model);
319 108 ▶ $deploy->_apply_extension_claims($model, $claims) if @$claims;
Branch: 1 branch
BranchTrueFalseTotal
if @$claims 68 40 108
320 106 my $triples = $self->annotate($model);
321 102 ▶ $deploy->_apply_extension_annotations($model, $triples) if @$triples;
Branch: 1 branch
BranchTrueFalseTotal
if @$triples 64 38 102
322 102 ▶ $deploy->_apply_extension_states($model, _clone($states)) if keys %$states;
Branch: 1 branch
BranchTrueFalseTotal
if keys %$states 62 40 102
323 }
324 51 $self->models(source => $models[0], target => $models[1]);
325 51 return @models;
326 }
327  
328 9 1;
329  
330 __END__
« blib/lib/DBIO/Relationship/ManyToMany.pm ↑ Summary blib/lib/DBIO/Admin.pm »