Meta/Role/FromSelect.pm

filter: Statementstmt 41.3% 24 / 58 Branchbran 0.0% 0 / 22 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 5 Subroutinesub 54.5% 6 / 11 Podpod n/a totaltotal 28.5% 30 / 105 SCAR 46.3
CC
15
Cov
27%
_make_sub_from_select
30.0
_make_default_from_select_with_type
20.0
__ANON__
20.0
CRAP 102.7
« Object/Table.pm ↑ Summary Object/Iterator/FromSelect.pm »
1 package Fey::Meta::Role::FromSelect;
2 {
3 10 $Fey::Meta::Role::FromSelect::VERSION = '0.46';
4 }
5  
6 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 ▶use Fey::ORM::Types qw( Bool CodeRef );
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Moose::Util::TypeConstraints qw( find_type_constraint );
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 10 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 10 has select => (
16 is => 'ro',
17 required => 1,
18 does => 'Fey::Role::SQL::ReturnsData',
19 );
20  
21 10 has bind_params => (
22 is => 'ro',
23 isa => CodeRef,
24 );
25  
26 10 has is_multi_column => (
27 is => 'ro',
28 isa => Bool,
29 default => 0,
30 );
31  
32 sub _make_sub_from_select {
33 0 ▶ my $class = shift;
Subroutine _make_sub_from_select: not called CC=5 SCAR=34.0
34 0 my $select = shift;
35 0 my $bind_sub = shift;
36 0 my $is_multi_col = shift;
37  
38 0 ▶ die 'The select parameter must be do the Fey::Role::SQL::ReturnsData role'
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($select) and $select->can("does") and $select->does("Fey::Role::SQL::ReturnsData") 0 0 0
Condition0%0/6
builtin::blessed($select) and $select->can("does") and $select->does("Fey::Role::SQL::ReturnsData")
!ll&&!rl&&r
000
builtin::blessed($select) and $select->can("does")
!ll&&!rl&&r
000
MC/DC0%0/3
builtin::blessed($select) and $select->can("does") and $select->does("Fey::Role::SQL::ReturnsData")
builtin::blessed($select) $select->can("does") $select->does("Fey::Role::SQL::ReturnsData")
Truth table0%0/4
A and B and C
A= builtin::blessed($select)B= $select->can("does")C= $select->does("Fey::Role::SQL::ReturnsData")
ABCresult
0XX0
10X0
1100
1111
39 unless blessed $select
40 && $select->can('does')
41 && $select->does('Fey::Role::SQL::ReturnsData');
42  
43 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 0 0 0
44 0 return $class->_make_default_from_select_with_type(
45 $select,
46 $bind_sub,
47 $is_multi_col,
48 shift,
49 );
50 }
51 else {
52 0 return $class->_make_default_from_select_without_type(
53 $select,
54 $bind_sub,
55 $is_multi_col
56 );
57 }
58 }
59  
60 sub _make_default_from_select_with_type {
61 0 ▶ my $class = shift;
Subroutine _make_default_from_select_with_type: not called CC=4 SCAR=30.0
62 0 my $select = shift;
63 0 my $bind_sub = shift;
64 0 my $is_multi_col = shift;
65 0 my $type = shift;
66  
67 0 my $wantarray = 0;
68 0 ▶ $wantarray = 1
Branch: 1 branch
BranchTrueFalseTotal
if defined $type and find_type_constraint($type)->is_a_type_of("ArrayRef") 0 0 0
Condition0%0/3
defined $type and find_type_constraint($type)->is_a_type_of("ArrayRef")
!ll&&!rl&&r
000
MC/DC0%0/2
defined $type and find_type_constraint($type)->is_a_type_of("ArrayRef")
defined $type find_type_constraint($type)->is_a_type_of("ArrayRef")
Truth table0%0/3
A and B
A= defined $typeB= find_type_constraint($type)->is_a_type_of("ArrayRef")
ABresult
0X0
100
111
69 if defined $type
70 && find_type_constraint($type)->is_a_type_of('ArrayRef');
71  
72 0 ▶ my $select_meth
Branch: 1 branch
BranchTrueFalseTotal
$is_multi_col ? : 0 0 0
73 = $is_multi_col ? 'selectall_arrayref' : 'selectcol_arrayref';
74  
75 return sub {
76 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
77  
78 0 my $dbh = $self->_dbh($select);
79  
80 0 ▶ my @select_p = (
Branch: 1 branch
BranchTrueFalseTotal
$bind_sub ? : 0 0 0
81 $select->sql($dbh), {},
82 $bind_sub ? $self->$bind_sub() : ()
83 );
84  
85 0 ▶ my $return = $dbh->$select_meth(@select_p)
Branch: 1 branch
BranchTrueFalseTotal
my $return = $dbh->$select_meth(@select_p) or return 0 0 0
86 or return;
87  
88 0 ▶ return $wantarray ? $return : $return->[0];
Branch: 1 branch
BranchTrueFalseTotal
$wantarray ? : 0 0 0
89 0 };
90 }
91  
92 sub _make_default_from_select_without_type {
93 0 ▶ my $class = shift;
Subroutine _make_default_from_select_without_type: not called CC=2 SCAR=17.9
94 0 my $select = shift;
95 0 my $bind_sub = shift;
96 0 my $is_multi_col = shift;
97  
98 0 ▶ my $select_meth
Branch: 1 branch
BranchTrueFalseTotal
$is_multi_col ? : 0 0 0
99 = $is_multi_col ? 'selectall_arrayref' : 'selectcol_arrayref';
100  
101 return sub {
102 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=4 SCAR=30.0
103  
104 0 my $dbh = $self->_dbh($select);
105  
106 0 ▶ my @select_p = (
Branch: 1 branch
BranchTrueFalseTotal
$bind_sub ? : 0 0 0
107 $select->sql($dbh), {},
108 $bind_sub ? $self->$bind_sub() : ()
109 );
110  
111 0 ▶ my $return = $dbh->$select_meth(@select_p)
Branch: 1 branch
BranchTrueFalseTotal
my $return = $dbh->$select_meth(@select_p) or return 0 0 0
112 or return;
113  
114 0 ▶ return wantarray ? @{$return} : $return->[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
115 0 };
116 }
117  
118 10 1;
« Object/Table.pm ↑ Summary Object/Iterator/FromSelect.pm »