Gideon/Driver.pm

filter: Statementstmt 32.2% 10 / 31 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 28.5% 2 / 7 Podpod 0.0% 0 / 5 totaltotal 16.9% 12 / 71 CC 12 SCAR 30.7
CC
12
Cov
18%
update
30.0
remove
30.0
save
20.0
CRAP 21.4
« Gideon/Driver/DBI.pm ↑ Summary Gideon/Plugin/StrictMode.pm »
1 package Gideon::Driver;
2 {
3 1 $Gideon::Driver::VERSION = '0.0.3';
4 }
5 1 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Gideon::Exceptions;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 #ABSTRACT: Gideon Driver Interface
9  
10 1 requires qw(_find _update _update_object _remove _remove_object _insert_object);
11  
12 0 ▶sub find {
Subroutine find: not called CC=1 SCAR=6.9
Pod undocumented
13 0 my ( $driver, $target, %query ) = @_;
14  
15 0 my $order = delete $query{-order};
16 0 $driver->_find( $target, \%query, $order );
17 }
18  
19 0 ▶sub find_one {
Subroutine find_one: not called CC=1 SCAR=6.9
Pod undocumented
20 0 my ( $driver, $target, %query ) = @_;
21  
22 0 my $order = delete $query{-order};
23 0 $driver->_find( $target, \%query, $order, 1 )->[0];
24 }
25  
26 0 ▶sub update {
Subroutine update: not called CC=5 SCAR=34.0
Pod undocumented
27 0 my ( $driver, $target, %changes ) = @_;
28  
29 0 my $is_object = ref $target;
30  
31 0 ▶ Gideon::Exception::ObjectNotInStore->throw
Branch: 1 branch
BranchTrueFalseTotal
if $is_object and not $target->__is_persisted 0 0 0
Condition0%0/3
$is_object and not $target->__is_persisted
!ll&&!rl&&r
000
MC/DC0%0/2
$is_object and not $target->__is_persisted
$is_object not $target->__is_persisted
Truth table0%0/3
A and not(B)
A= $is_objectB= not $target->__is_persisted
ABresult
0X0
100
111
32 if $is_object and not $target->__is_persisted;
33  
34 0 ▶ my $result =
Branch: 1 branch
BranchTrueFalseTotal
$is_object ? : 0 0 0
35 $is_object
36 ? $driver->_update_object( $target, \%changes )
37 : $driver->_update( $target, \%changes, {} );
38  
39 0 ▶ return $target if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 0 0 0
40 }
41  
42 0 ▶sub remove {
Subroutine remove: not called CC=5 SCAR=34.0
Pod undocumented
43 0 my ( $driver, $target, %query ) = @_;
44  
45 0 my $is_object = ref $target;
46  
47 0 ▶ Gideon::Exception::ObjectNotInStore->throw
Branch: 1 branch
BranchTrueFalseTotal
if $is_object and not $target->__is_persisted 0 0 0
Condition0%0/3
$is_object and not $target->__is_persisted
!ll&&!rl&&r
000
MC/DC0%0/2
$is_object and not $target->__is_persisted
$is_object not $target->__is_persisted
Truth table0%0/3
A and not(B)
A= $is_objectB= not $target->__is_persisted
ABresult
0X0
100
111
48 if $is_object and not $target->__is_persisted;
49  
50 0 ▶ my $result =
Branch: 1 branch
BranchTrueFalseTotal
$is_object ? : 0 0 0
51 $is_object
52 ? $driver->_remove_object($target)
53 : $driver->_remove( $target, \%query );
54  
55 0 ▶ return $target if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 0 0 0
56 }
57  
58 0 ▶sub save {
Subroutine save: not called CC=4 SCAR=30.0
Pod undocumented
59 0 my ( $class, $target ) = @_;
60  
61 0 my $is_object = ref $target;
62  
63 0 ▶ Gideon::Exception::InvalidOperation->throw unless $is_object;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_object 0 0 0
64  
65 0 ▶ my $result =
Branch: 1 branch
BranchTrueFalseTotal
$target->__is_persisted ? : 0 0 0
66 $target->__is_persisted
67 ? $class->_update_object($target)
68 : $class->_insert_object($target);
69  
70 0 ▶ return $target if $result;
Branch: 1 branch
BranchTrueFalseTotal
if $result 0 0 0
71 }
72  
73 1 1;
74  
75 __END__
« Gideon/Driver/DBI.pm ↑ Summary Gideon/Plugin/StrictMode.pm »