DBI/Relationship/MightHave.pm

filter: Statementstmt 21.2% 10 / 47 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 25.0% 3 / 12 Podpod 100% 3 / 3 totaltotal 18.8% 16 / 85 CC 8 SCAR 20.9
CC
8
Cov
16%
__ANON__
20.0
__ANON__
12.0
__ANON__
6.0
CRAP 8.1
« DBI/Search/Basic.pm ↑ Summary DBI/SQL/Transformer.pm »
1 package Class::DBI::Relationship::MightHave;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 ▶use base 'Class::DBI::Relationship';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶sub remap_arguments {
Subroutine remap_arguments: not called CC=1 SCAR=6.9
Pod documented
9 0 my ($proto, $class, $method, $f_class, @methods) = @_;
10 0 $class->_require_class($f_class);
11 0 return ($class, $method, $f_class, { import => \@methods });
12 }
13  
14 0 ▶sub triggers {
Subroutine triggers: not called CC=1 SCAR=6.9
Pod documented
15 0 my $self = shift;
16  
17 0 my $method = $self->accessor;
18  
19 return (
20 0 ▶ before_update => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
21 0 ▶ if (my $for_obj = shift->$method()) { $for_obj->update }
Branch: 1 branch
BranchTrueFalseTotal
if (my $for_obj = (shift())->$method) 0 0 0
22 },
23  
24 0 ▶ before_delete => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
25 0 ▶ if (my $for_obj = shift->$method()) { $for_obj->delete }
Branch: 1 branch
BranchTrueFalseTotal
if (my $for_obj = (shift())->$method) 0 0 0
26 },
27 0 );
28 }
29  
30 0 ▶sub methods {
Subroutine methods: not called CC=1 SCAR=6.9
Pod documented
31 0 my $self = shift;
32 0 my ($class, $method) = ($self->class, $self->accessor);
33 return (
34 $method => $self->_object_accessor,
35 0 map { $_ => $self->_imported_accessor($_) } @{ $self->args->{import} }
36 );
37 }
38  
39 0 ▶sub _object_accessor {
Subroutine _object_accessor: not called CC=1 SCAR=6.9
40 0 my $rel = shift;
41 0 my ($class, $method) = ($rel->class, $rel->accessor);
42 0 ▶ return sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
43 0 my $self = shift;
44 0 my $meta = $class->meta_info($rel->name => $method);
45 my ($f_class, @extra) =
46 0 ($meta->foreign_class, @{ $meta->args->{import} });
47 return
48 if defined($self->{"_${method}_object"})
49 0 ▶ && $self->{"_${method}_object"}
Branch: 1 branch
BranchTrueFalseTotal
if defined $$self{"_${method}_object"} and $$self{"_${method}_object"}->isa("Class::DBI::Object::Has::Been::Deleted") 0 0 0
Condition0%0/3
defined $$self{"_${method}_object"} and $$self{"_${method}_object"}->isa("Class::DBI::Object::Has::Been::Deleted")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $$self{"_${method}_object"} and $$self{"_${method}_object"}->isa("Class::DBI::Object::Has::Been::Deleted")
defined $$self{"_${method}_object"} $$self{"_${method}_object"}->isa("Class::DBI::Object::Has::Been::Deleted")
Truth table0%0/3
A and B
A= defined $$self{"_${method}_object"}B= $$self{"_${method}_object"}->isa("Class::DBI::Object::Has::Been::Deleted")
ABresult
0X0
100
111
50 ->isa('Class::DBI::Object::Has::Been::Deleted');
51 0 ▶ $self->{"_${method}_object"} ||= $f_class->retrieve($self->id);
Condition0%0/3
$$self{"_${method}_object"} ||= $f_class->retrieve($self->id)
l!l&&r!l&&!r
000
MC/DC0%0/2
$$self{"_${method}_object"} ||= $f_class->retrieve($self->id)
$$self{"_${method}_object"} $f_class->retrieve($self->id)
Truth table0%0/3
A ||= B
A= $$self{"_${method}_object"}B= $f_class->retrieve($self->id)
ABresult
1X1
011
000
52 0 };
53 }
54  
55 0 ▶sub _imported_accessor {
Subroutine _imported_accessor: not called CC=1 SCAR=6.9
56 0 my ($rel, $name) = @_;
57 0 my ($class, $method) = ($rel->class, $rel->accessor);
58 0 ▶ return sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
59 0 my $self = shift;
60 0 my $meta = $class->meta_info($rel->name => $method);
61 my ($f_class, @extra) =
62 0 ($meta->foreign_class, @{ $meta->args->{import} });
63 0 ▶ my $for_obj = $self->$method() || do {
Condition0%0/3
$self->$method || do { return unless @_; my $val = shift(); $f_class->insert({$f_class->primary_column, $self->id, $name, $val}); $self->$method }
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->$method || do { return unless @_; my $val = shift(); $f_class->insert({$f_class->primary_column, $self->id, $name, $val}); $self->$method }
$self->$method do { return unless @_; my $val = shift(); $f_class->insert({$f_class->primary_column, $self->id, $name, $val}); $self->$method }
Truth table0%0/3
A || B
A= $self->$methodB= do { return unless @_; my $val = shift(); $f_class->insert({$f_class->primary_column, $self->id, $name, $val}); $self->$method }
ABresult
1X1
011
000
64 0 ▶ return unless @_; # just fetching
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
65 0 my $val = shift;
66 0 $f_class->insert(
67 { $f_class->primary_column => $self->id, $name => $val });
68 0 $self->$method();
69 };
70 0 $for_obj->$name(@_);
71 0 };
72 }
73  
74 4 1;
« DBI/Search/Basic.pm ↑ Summary DBI/SQL/Transformer.pm »