Object/Metadata/ForeignKey.pm

filter: Statementstmt 53.2% 90 / 169 Branchbran 30.4% 25 / 82 Conditioncond 27.2% 9 / 33 MC/DCmcdc 10.0% 2 / 20 Subroutinesub 60.6% 20 / 33 Podpod 27.2% 6 / 22 totaltotal 42.3% 152 / 359 CC 60 SCAR 38.0
CC
60
Cov
44%
perl_hash_definition
210.0
spec_hash
56.0
make_methods
37.4
CRAP 44.6
« Object/Metadata.pm ↑ Summary Object/Metadata/Column/Varchar.pm »
1 package Rose::DB::Object::Metadata::ForeignKey;
2  
3 61 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 61 ▶use Carp();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 61 ▶use Scalar::Util();
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 61 ▶use Rose::DB::Object::Metadata::Util qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 61 ▶use Rose::DB::Object::Metadata::Column;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 61 our @ISA = qw(Rose::DB::Object::Metadata::Column);
12  
13 61 ▶use Rose::DB::Object::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 61 our $VERSION = '0.784';
16  
17 61 our $Debug = 0;
18  
19 use overload
20 61 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 # "Undo" inherited overloaded stringification.
22 # (Using "no overload ..." didn't seem to work.)
23 1092 ▶ '""' => sub { overload::StrVal($_[0]) },
Subroutine __ANON__: called CC=1 SCAR=0.0
24 61 fallback => 1,
25 61 );
26  
27 61 __PACKAGE__->default_auto_method_types(qw(get_set_on_save delete_on_save));
28  
29 61 __PACKAGE__->add_common_method_maker_argument_names
30 (
31 qw(hash_key share_db class key_columns foreign_key referential_integrity)
32 );
33  
34 use Rose::Object::MakeMethods::Generic
35 61 ▶(
Subroutine BEGIN: called CC=1 SCAR=0.0
36 61 boolean =>
37 [
38 'share_db' => { default => 1 },
39 'referential_integrity' => { default => 1 },
40 'with_column_triggers' => { default => 0 },
41 'disable_column_triggers',
42 ],
43  
44 scalar => 'deferred_make_method_args',
45  
46 hash =>
47 [
48 _key_column => { hash_key => '_key_columns' },
49 _key_columns => { interface => 'get_set_all' },
50 ],
51 61 );
52  
53 0 ▶sub is_singular { 1 }
Subroutine is_singular: not called CC=1 SCAR=6.9
Pod undocumented
54  
55 0 ▶sub foreign_class { shift->class(@_) }
Subroutine foreign_class: not called CC=1 SCAR=6.9
Pod undocumented
56  
57 sub key_column
58 0 ▶{
Subroutine key_column: not called CC=2 SCAR=17.9
Pod documented
59 0 my($self) = shift;
60  
61 0 ▶ if(@_ > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) 0 0 0
62 {
63 0 $self->{'is_required'} = undef;
64 }
65  
66 0 return $self->_key_column(@_);
67 }
68  
69 sub key_columns
70 1096 ▶{
Subroutine key_columns: called CC=2 SCAR=6.9
Pod documented
71 1096 my($self) = shift;
72  
73 1096 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 32 1064 1096
74 {
75 32 $self->{'is_required'} = undef;
76 }
77  
78 1096 return $self->_key_columns(@_);
79 }
80  
81 61 *column_map = \&key_columns;
82  
83 61 Rose::Object::MakeMethods::Generic->make_methods
84 (
85 { preserve_existing => 1 },
86 scalar =>
87 [
88 __PACKAGE__->common_method_maker_argument_names,
89 relationship_type => { interface => 'get_set_init' },
90 ],
91 );
92  
93 61 *rel_type = \&relationship_type;
94  
95 61 __PACKAGE__->method_maker_info
96 (
97 get_set =>
98 {
99 class => 'Rose::DB::Object::MakeMethods::Generic',
100 type => 'object_by_key',
101 interface => 'get_set',
102 },
103  
104 get_set_now =>
105 {
106 class => 'Rose::DB::Object::MakeMethods::Generic',
107 type => 'object_by_key',
108 interface => 'get_set_now',
109 },
110  
111 get_set_on_save =>
112 {
113 class => 'Rose::DB::Object::MakeMethods::Generic',
114 type => 'object_by_key',
115 interface => 'get_set_on_save',
116 },
117  
118 delete_now =>
119 {
120 class => 'Rose::DB::Object::MakeMethods::Generic',
121 type => 'object_by_key',
122 interface => 'delete_now',
123 },
124  
125 delete_on_save =>
126 {
127 class => 'Rose::DB::Object::MakeMethods::Generic',
128 type => 'object_by_key',
129 interface => 'delete_on_save',
130 },
131 );
132  
133 32 ▶sub init_relationship_type { 'many to one' }
Subroutine init_relationship_type: called CC=1 SCAR=0.0
Pod undocumented
134  
135 208 ▶sub foreign_key { $_[0] }
Subroutine foreign_key: called CC=1 SCAR=0.0
Pod undocumented
136  
137 312 ▶sub type { 'foreign key' }
Subroutine type: called CC=1 SCAR=0.0
Pod documented
138  
139 sub soft
140 0 ▶{
Subroutine soft: not called CC=2 SCAR=17.9
Pod documented
141 0 my($self) = shift;
142  
143 0 ▶ if(@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
144 {
145 0 $self->referential_integrity(!$_[0]);
146 }
147  
148 0 return ! $self->referential_integrity;
149 }
150  
151 sub is_required
152 52 ▶{
Subroutine is_required: called CC=7 SCAR=20.5
Pod undocumented
153 52 my($self) = shift;
154  
155 52 ▶ return $self->{'required'} if(defined $self->{'required'});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"required"} 0 52 52
156 52 ▶ return $self->{'is_required'} if(defined $self->{'is_required'});
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"is_required"} 20 32 52
157  
158 32 ▶ my $meta = $self->parent or
Branch: 1 branch
BranchTrueFalseTotal
my $meta = $self->parent or Carp::croak("Missing parent for foreign key '", $self->name, "'") 32 0 32
159 Carp::croak "Missing parent for foreign key '", $self->name, "'";
160  
161 32 my $key_columns = $self->key_columns;
162  
163 # If any local key column allows null values, then
164 # the foreign object is not required.
165 32 foreach my $column_name (keys %$key_columns)
166 {
167 32 ▶ my $column = $meta->column($column_name)
Branch: 1 branch
BranchTrueFalseTotal
my $column = $meta->column($column_name) or Carp::confess("No such column '${column_name}' in table '", $self->parent->table, "' referenced from foreign key '", $self->name, "'") 32 0 32
168 or Carp::confess "No such column '$column_name' in table '",
169 $self->parent->table, "' referenced from foreign key '",
170 $self->name, "'";
171  
172 32 ▶ unless($column->not_null)
Branch: 1 branch
BranchTrueFalseTotal
unless ($column->not_null) 32 0 32
173 {
174 32 return $self->{'is_required'} = 0;
175 }
176 }
177  
178 0 return $self->{'is_required'} = 1;
179 }
180  
181 sub make_methods
182 52 ▶{
Subroutine make_methods: called CC=7 SCAR=36.2
Pod documented
183 52 my($self) = shift;
184 52 $self->is_required; # initialize
185 52 $self->SUPER::make_methods(@_);
186  
187 52 ▶ if($self->with_column_triggers)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->with_column_triggers) 0 52 52
188 {
189 0 ▶ my $method = $self->method_name('get_set_on_save') ||
Condition0%0/3
$self->method_name('get_set_on_save') || $self->method_name('get_set')
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->method_name('get_set_on_save') || $self->method_name('get_set')
$self->method_name('get_set_on_save') $self->method_name('get_set')
Truth table0%0/3
A || B
A= $self->method_name('get_set_on_save')B= $self->method_name('get_set')
ABresult
1X1
011
000
190 $self->method_name('get_set');
191  
192 0 ▶ if($method)
Branch: 1 branch
BranchTrueFalseTotal
if ($method) 0 0 0
193 {
194 0 ▶ my $meta = $self->parent or
Branch: 1 branch
BranchTrueFalseTotal
my $meta = $self->parent or Carp::croak("Missing parent for foreign key '", $self->name, "'") 0 0 0
195 Carp::croak "Missing parent for foreign key '", $self->name, "'";
196  
197 0 my $key_columns = $self->key_columns;
198  
199 0 foreach my $column_name (keys %$key_columns)
200 {
201 0 my $column = $meta->column($column_name);
202 0 my $accessor = $column->accessor_method_name;
203 0 my $trigger_name = 'clear_fk' . $self->name;
204  
205 0 ▶ unless(defined $column->builtin_trigger_index('on_set', $trigger_name))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $column->builtin_trigger_index("on_set", $trigger_name)) 0 0 0
206 {
207 0 Scalar::Util::weaken(my $wolumn = $column);
208  
209 $column->add_builtin_trigger(
210 event => 'on_set',
211 name => $trigger_name,
212 code => sub
213 0 ▶ {
Subroutine __ANON__: not called CC=3 SCAR=24.8
214 0 my($obj) = shift;
215 0 ▶ return if($self->{'disable_column_triggers'});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"disable_column_triggers"} 0 0 0
216 0 local $wolumn->{'triggers_disabled'} = 1;
217 0 ▶ $obj->$method(undef) unless(defined $obj->$accessor());
Branch: 1 branch
BranchTrueFalseTotal
unless defined $obj->$accessor 0 0 0
218 0 });
219 }
220 }
221 }
222 }
223 }
224  
225 sub build_method_name_for_type
226 64 ▶{
Subroutine build_method_name_for_type: called CC=6 SCAR=20.9
Pod documented
227 64 my($self, $type) = @_;
228  
229 64 ▶ if($type eq 'get_set' || $type eq 'get_set_now' || $type eq 'get_set_on_save')
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'get_set' or $type eq 'get_set_now' or $type eq 'get_set_on_save') { } 32 32 64
elsif ($type eq 'delete_now' or $type eq 'delete_on_save') { } 32 0 32
Condition50%3/6
$type eq "get_set" or $type eq "get_set_now" or $type eq "get_set_on_save"
l!l&&r!l&&!r
03232
$type eq "get_set" or $type eq "get_set_now"
l!l&&r!l&&!r
0064
MC/DC33%1/3
$type eq "get_set" or $type eq "get_set_now" or $type eq "get_set_on_save"
$type eq "get_set" $type eq "get_set_now" $type eq "get_set_on_save"
Truth table50%2/4
A or B or C
A= $type eq "get_set"B= $type eq "get_set_now"C= $type eq "get_set_on_save"
ABCresult
1XX1
01X1
0011
0000
230 {
231 32 return $self->name;
232 }
233 ▶ elsif($type eq 'delete_now' || $type eq 'delete_on_save')
Condition33%1/3
$type eq "delete_now" or $type eq "delete_on_save"
l!l&&r!l&&!r
0320
MC/DC0%0/2
$type eq "delete_now" or $type eq "delete_on_save"
$type eq "delete_now" $type eq "delete_on_save"
Truth table33%1/3
A or B
A= $type eq "delete_now"B= $type eq "delete_on_save"
ABresult
1X1
011
000
234 {
235 32 return 'delete_' . $self->name;
236 }
237  
238 0 return undef;
239 }
240  
241 sub id
242 244 ▶{
Subroutine id: called CC=1 SCAR=0.0
Pod undocumented
243 244 my($self) = shift;
244  
245 244 my $key_columns = $self->key_columns;
246  
247 return $self->parent->class . ' ' . $self->class . ' ' .
248 244 join("\0", map { join("\1", lc $_, lc $key_columns->{$_}) } sort keys %$key_columns) .
249 #join("\0", map { $_ . '=' . ($self->$_() || 0) } qw(...));
250 'required=' . $self->referential_integrity;
251 }
252  
253 sub sanity_check
254 112 ▶{
Subroutine sanity_check: called CC=3 SCAR=11.8
Pod undocumented
255 112 my($self) = shift;
256  
257 112 my $key_columns = $self->key_columns;
258  
259 61 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
260 112 ▶ unless(ref $key_columns eq 'HASH' && keys %$key_columns)
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $key_columns eq "HASH" and keys %$key_columns) 0 112 112
Condition33%1/3
ref $key_columns eq "HASH" and keys %$key_columns
!ll&&!rl&&r
00112
MC/DC0%0/2
ref $key_columns eq "HASH" and keys %$key_columns
ref $key_columns eq "HASH" keys %$key_columns
Truth table33%1/3
A and B
A= ref $key_columns eq "HASH"B= keys %$key_columns
ABresult
0X0
100
111
261 {
262 #Carp::croak "Foreign key '", $self->name, "' is missing a key_columns";
263 0 return;
264 }
265  
266 112 return 1;
267 }
268  
269 sub is_ready_to_make_methods
270 100 ▶{
Subroutine is_ready_to_make_methods: called CC=14 SCAR=29.2
Pod undocumented
271 100 my($self) = shift;
272  
273 100 ▶ return 0 unless($self->sanity_check);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->sanity_check 0 100 100
274  
275 100 my $error;
276  
277 TRY:
278 {
279 100 local $@;
280  
281 eval
282 100 {
283 # Workaround for http://rt.perl.org/rt3/Ticket/Display.html?id=60890
284 100 local $SIG{'__DIE__'};
285  
286 100 ▶ $self->class->isa('Rose::DB::Object') or die
Branch: 1 branch
BranchTrueFalseTotal
$self->class->isa("Rose::DB::Object") or die "Rose::DB::Object::Exception::ClassNotReady"->new("Missing or invalid foreign class") 100 0 100
287 Rose::DB::Object::Exception::ClassNotReady->new(
288 "Missing or invalid foreign class");
289  
290 100 ▶ my $fk_meta = $self->class->meta or die
Branch: 1 branch
BranchTrueFalseTotal
my $fk_meta = $self->class->meta or die "Rose::DB::Object::Exception::ClassNotReady"->new('Missing meta object for ' . $self->class) 100 0 100
291 Rose::DB::Object::Exception::ClassNotReady->new(
292 "Missing meta object for " . $self->class);
293  
294 100 ▶ my $key_columns = $self->key_columns || {};
Condition50%1/2
$self->key_columns || {}
l!l
1000
MC/DC0%0/1
$self->key_columns || {}
$self->key_columns
Truth table50%1/2
A
A= $self->key_columns
Aresult
11
00
295  
296 100 foreach my $column_name (values %$key_columns)
297 {
298 100 ▶ unless($fk_meta->column($column_name))
Branch: 1 branch
BranchTrueFalseTotal
unless ($fk_meta->column($column_name)) 0 100 100
299 {
300 0 die Rose::DB::Object::Exception::ClassNotReady->new(
301 "No column '$column_name' in class " . $fk_meta->class);
302 }
303  
304 100 ▶ unless($fk_meta->column_accessor_method_name($column_name) &&
Branch: 1 branch
BranchTrueFalseTotal
unless ($fk_meta->column_accessor_method_name($column_name) and $fk_meta->column_mutator_method_name($column_name)) 48 52 100
Condition66%2/3
$fk_meta->column_accessor_method_name($column_name) and $fk_meta->column_mutator_method_name($column_name)
!ll&&!rl&&r
48052
MC/DC50%1/2
$fk_meta->column_accessor_method_name($column_name) and $fk_meta->column_mutator_method_name($column_name)
$fk_meta->column_accessor_method_name($column_name) $fk_meta->column_mutator_method_name($column_name)
Truth table66%2/3
A and B
A= $fk_meta->column_accessor_method_name($column_name)B= $fk_meta->column_mutator_method_name($column_name)
ABresult
0X0
100
111
305 $fk_meta->column_mutator_method_name($column_name))
306 {
307 48 die Rose::DB::Object::Exception::ClassNotReady->new(
308 "Foreign class not initialized");
309 }
310 }
311 };
312  
313 100 $error = $@;
314 }
315  
316 100 ▶ if($error)
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 48 52 100
317 {
318 48 ▶ if($Debug || $Rose::DB::Object::Metadata::Debug)
Branch: 1 branch
BranchTrueFalseTotal
if ($Rose::DB::Object::Metadata::ForeignKey::Debug or $Rose::DB::Object::Metadata::Debug) 0 48 48
Condition33%1/3
$Rose::DB::Object::Metadata::ForeignKey::Debug or $Rose::DB::Object::Metadata::Debug
l!l&&r!l&&!r
0048
MC/DC0%0/2
$Rose::DB::Object::Metadata::ForeignKey::Debug or $Rose::DB::Object::Metadata::Debug
$Rose::DB::Object::Metadata::ForeignKey::Debug $Rose::DB::Object::Metadata::Debug
Truth table33%1/3
A or B
A= $Rose::DB::Object::Metadata::ForeignKey::DebugB= $Rose::DB::Object::Metadata::Debug
ABresult
1X1
011
000
319 {
320 0 my $err = $error;
321 0 $err =~ s/ at .*//;
322 0 warn $self->parent->class, ': Foreign key ', $self->name, " NOT READY - $err";
323 }
324  
325 48 ▶ die $error unless(UNIVERSAL::isa($error, 'Rose::DB::Object::Exception::ClassNotReady'));
Branch: 1 branch
BranchTrueFalseTotal
unless UNIVERSAL::isa($error, "Rose::DB::Object::Exception::ClassNotReady") 0 48 48
326 }
327  
328 100 ▶ return $error ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$error ? : 48 52 100
329 }
330  
331 61 our $DEFAULT_INLINE_LIMIT = 80;
332  
333 sub perl_hash_definition
334 0 ▶{
Subroutine perl_hash_definition: not called CC=14 SCAR=53.5
Pod undocumented
335 0 my($self, %args) = @_;
336  
337 0 my $meta = $self->parent;
338  
339 0 ▶ my $indent = defined $args{'indent'} ? $args{'indent'} :
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'indent'} ? : 0 0 0
$meta ? : 0 0 0
340 ($meta ? $meta->default_perl_indent : undef);
341  
342 0 ▶ my $braces = defined $args{'braces'} ? $args{'braces'} :
Branch: 2 branches
BranchTrueFalseTotal
defined $args{'braces'} ? : 0 0 0
$meta ? : 0 0 0
343 ($meta ? $meta->default_perl_braces : undef);
344  
345 0 ▶ my $inline = defined $args{'inline'} ? $args{'inline'} : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'inline'} ? : 0 0 0
346 0 ▶ my $inline_limit = defined $args{'inline'} ? $args{'inline_limit'} : $DEFAULT_INLINE_LIMIT;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'inline'} ? : 0 0 0
347  
348 0 my $name_padding = $args{'name_padding'};
349  
350 0 my %attrs = map { $_ => 1 } $self->perl_foreign_key_definition_attributes;
351 0 my %hash = $self->spec_hash;
352  
353 0 my @delete_keys = grep { !$attrs{$_} } keys %hash;
354 0 delete @hash{@delete_keys};
355  
356 0 my $key_columns = $self->key_columns;
357  
358 # Only inline single-pair key column mappings
359 0 ▶ if(keys %$key_columns > 1)
Branch: 1 branch
BranchTrueFalseTotal
if (keys %$key_columns > 1) 0 0 0
360 {
361 0 $inline_limit = 1;
362 0 $inline = 0;
363 }
364  
365 0 my $max_len = 0;
366 0 my $min_len = -1;
367  
368 0 foreach my $name (keys %hash)
369 {
370 0 ▶ $max_len = length($name) if(length $name > $max_len);
Branch: 1 branch
BranchTrueFalseTotal
if length $name > $max_len 0 0 0
371 0 ▶ $min_len = length($name) if(length $name < $min_len || $min_len < 0);
Branch: 1 branch
BranchTrueFalseTotal
if length $name < $min_len or $min_len < 0 0 0 0
Condition0%0/3
length $name < $min_len or $min_len < 0
l!l&&r!l&&!r
000
MC/DC0%0/2
length $name < $min_len or $min_len < 0
length $name < $min_len $min_len < 0
Truth table0%0/3
A or B
A= length $name < $min_lenB= $min_len < 0
ABresult
1X1
011
000
372 }
373  
374 0 ▶ if(defined $name_padding && $name_padding > 0)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name_padding and $name_padding > 0) { } 0 0 0
Condition0%0/3
defined $name_padding and $name_padding > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $name_padding and $name_padding > 0
defined $name_padding $name_padding > 0
Truth table0%0/3
A and B
A= defined $name_paddingB= $name_padding > 0
ABresult
0X0
100
111
375 {
376 0 return sprintf('%-*s => ', $name_padding, perl_quote_key($self->name)) .
377 perl_hashref(hash => \%hash,
378 braces => $braces,
379 inline => $inline,
380 inline_limit => $inline_limit,
381 indent => $indent,
382 key_padding => hash_key_padding(\%hash));
383 }
384 else
385 {
386 0 return perl_quote_key($self->name) . ' => ' .
387 perl_hashref(hash => \%hash,
388 braces => $braces,
389 inline => $inline,
390 inline_limit => $inline_limit,
391 indent => $indent,
392 key_padding => hash_key_padding(\%hash));
393 }
394 }
395  
396 0 ▶sub perl_foreign_key_definition_attributes { qw(class key_columns soft rel_type) }
Subroutine perl_foreign_key_definition_attributes: not called CC=1 SCAR=6.9
Pod undocumented
397  
398 # Some object keys have different names when they appear
399 # in hashref-style foreign key specs. This hash maps
400 # between the two in the case where they differ.
401 sub spec_hash_map
402 0 ▶{
Subroutine spec_hash_map: not called CC=1 SCAR=6.9
Pod undocumented
403 {
404 # object key spec key
405 0 method_name => 'methods',
406 _key_columns => 'key_columns',
407 relationship_type => 'rel_type',
408 }
409 }
410  
411 # Return a hashref-style foreign key spec
412 sub spec_hash
413 0 ▶{
Subroutine spec_hash: not called CC=7 SCAR=40.3
Pod undocumented
414 0 my($self) = shift;
415  
416 0 ▶ my $map = $self->spec_hash_map || {};
Condition0%0/2
$self->spec_hash_map || {}
l!l
00
MC/DC0%0/1
$self->spec_hash_map || {}
$self->spec_hash_map
Truth table0%0/2
A
A= $self->spec_hash_map
Aresult
11
00
417  
418 0 my %spec;
419  
420 0 foreach my $key (keys(%$self))
421 {
422 0 ▶ if(exists $map->{$key})
Branch: 1 branch
BranchTrueFalseTotal
if (exists $map->{$key}) { } 0 0 0
423 {
424 0 ▶ my $spec_key = $map->{$key} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $spec_key = $map->{$key} or next 0 0 0
425 0 $spec{$spec_key} = $self->{$key};
426 }
427 else
428 {
429 0 $spec{$key} = $self->{$key};
430 }
431 }
432  
433 # Don't include this key if it has the default value. Anal, I know...
434 0 ▶ delete $spec{'rel_type'} if($spec{'rel_type'} eq $self->init_relationship_type);
Branch: 1 branch
BranchTrueFalseTotal
if $spec{"rel_type"} eq $self->init_relationship_type 0 0 0
435  
436 0 ▶ return wantarray ? %spec : \%spec;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
437 }
438  
439 sub object_has_foreign_object
440 0 ▶{
Subroutine object_has_foreign_object: not called CC=3 SCAR=24.8
Pod undocumented
441 0 my($self, $object) = @_;
442  
443 0 ▶ unless($object->isa($self->parent->class))
Branch: 1 branch
BranchTrueFalseTotal
unless ($object->isa($self->parent->class)) 0 0 0
444 {
445 0 my $class = $self->parent->class;
446 0 Carp::croak "Cannot check for foreign object related through the ", $self->name,
447 " foreign key. Object does not inherit from $class: $object";
448 }
449  
450 0 ▶ return $object->{$self->hash_key} || 0;
Condition0%0/2
$$object{$self->hash_key} || 0
l!l
00
MC/DC0%0/1
$$object{$self->hash_key} || 0
$$object{$self->hash_key}
Truth table0%0/2
A
A= $$object{$self->hash_key}
Aresult
11
00
451 }
452  
453 0 ▶sub hash_keys_used { shift->hash_key }
Subroutine hash_keys_used: not called CC=1 SCAR=6.9
Pod undocumented
454  
455 sub forget_foreign_object
456 0 ▶{
Subroutine forget_foreign_object: not called CC=2 SCAR=17.9
Pod undocumented
457 0 my($self, $object) = @_;
458  
459 0 foreach my $key ($self->hash_keys_used)
460 {
461 0 $object->{$key} = undef;
462 }
463 }
464  
465 0 ▶sub requires_preexisting_parent_object { 0 }
Subroutine requires_preexisting_parent_object: not called CC=1 SCAR=6.9
Pod undocumented
466  
467 61 1;
468  
469 __END__
« Object/Metadata.pm ↑ Summary Object/Metadata/Column/Varchar.pm »