| 1 | package Data::Mapper::Data; | ||||||||||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 2 | ▶ | use parent qw(Data::Mapper::Class); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 2 | ▶ | use Carp (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 10 | ▶ | sub param { | ||||||||||||||||||
|
Subroutine
param: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 9 | 10 | my $self = shift; | |||||||||||||||||||
| 10 | 10 | ▶ | return keys %$self if !@_; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 9 | ▶ | if (@_ == 1) { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 13 | 5 | my $key = shift; | |||||||||||||||||||
| 14 | 5 | return $self->{$key}; | |||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | ▶ | elsif (@_ && @_ % 2 == 0) { | |||||||||||||||||||
|
Condition66%2/3
@_ and @_ % 2 == 0
MC/DC50%1/2
@_ and @_ % 2 == 0
@_
@_ % 2 == 0
Truth table66%2/3
A and B
A= @_B= @_ % 2 == 0
| |||||||||||||||||||||
| 17 | 3 | my %args = @_; | |||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | 3 | ▶ | while (my ($key, $value) = each %args) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | 4 | $self->{$key} = $value; | |||||||||||||||||||
| 21 | 4 | $self->mark_as_changed($key); | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 3 | return $self; | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | else { | ||||||||||||||||||||
| 27 | 1 | Carp::croak('arguments count must be an even number'); | |||||||||||||||||||
| 28 | } | ||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 2 | my %CHANGES; | |||||||||||||||||||
| 32 | 16 | ▶ | sub changed_keys { | ||||||||||||||||||
|
Subroutine
changed_keys: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||
| 33 | 16 | my ($self, $changed_keys) = @_; | |||||||||||||||||||
| 34 | 16 | ▶ | $CHANGES{$self + 0} ||= []; | ||||||||||||||||||
|
Condition100%2/2
$CHANGES{$self + 0} ||= []
MC/DC100%1/1
$CHANGES{$self + 0} ||= []
$CHANGES{$self + 0}
Truth table100%2/2
A
A= $CHANGES{$self + 0}
| |||||||||||||||||||||
| 35 | 16 | ▶ | $CHANGES{$self + 0} = $changed_keys if defined $changed_keys; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 36 | 16 | $CHANGES{$self + 0}; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 3 | ▶ | sub changes { | ||||||||||||||||||
|
Subroutine
changes: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 40 | 3 | my $self = shift; | |||||||||||||||||||
| 41 | 3 | my $changes = {}; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 3 | for my $key (@{$self->changed_keys}) { | |||||||||||||||||||
| 44 | 1 | $changes->{$key} = $self->param($key); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 3 | $changes; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 4 | ▶ | sub mark_as_changed { | ||||||||||||||||||
|
Subroutine
mark_as_changed: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 51 | 4 | my ($self, $key) = @_; | |||||||||||||||||||
| 52 | 4 | push @{$self->changed_keys}, $key; | |||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 3 | ▶ | sub is_changed { | ||||||||||||||||||
|
Subroutine
is_changed: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 56 | 3 | my $self = shift; | |||||||||||||||||||
| 57 | 3 | scalar @{$self->changed_keys} > 0; | |||||||||||||||||||
| 58 | } | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 3 | ▶ | sub discard_changes { | ||||||||||||||||||
|
Subroutine
discard_changes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 61 | 3 | my $self = shift; | |||||||||||||||||||
| 62 | 3 | $self->changed_keys([]); | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | 2 | ▶ | sub DESTROY { | ||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 66 | 2 | my $self = shift; | |||||||||||||||||||
| 67 | 2 | $self->discard_changes; | |||||||||||||||||||
| 68 | } | ||||||||||||||||||||
| 69 | |||||||||||||||||||||
| 70 | 2 | !!1; | |||||||||||||||||||