| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
defined $$self{"_${method}_object"} and $$self{"_${method}_object"}->isa("Class::DBI::Object::Has::Been::Deleted")
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")
| |||||||||||||||||||||||||||||
| 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)
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)
| |||||||||||||||||||||||||||||
| 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
}
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
}
| |||||||||||||||||||||||||||||
| 64 | 0 | ▶ | return unless @_; # just fetching | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||