Storage/Statement.pm

filter: Statementstmt 46.5% 20 / 43 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 46.6% 7 / 15 Podpod 100% 5 / 5 totaltotal 43.2% 32 / 74 CC 5 SCAR 17.5
CC
5
Cov
38%
bind_param_inout
20.0
Statement
6.0
DEFAULTS
2.0
CRAP 5.8
« Storage/DBI.pm ↑ Summary Storage/DBI/SQLite.pm »
1 6 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Data::Storage::Statement;
6 6 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 $Data::Storage::Statement::VERSION = '1.102720';
8 }
9 # ABSTRACT: Wrapper for DBI statements
10 6 ▶use Data::Miscellany 'value_of';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 6 ▶use parent qw(Class::Accessor::Complex Class::Accessor::Constructor);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 6 __PACKAGE__
13 ->mk_constructor
14 ->mk_scalar_accessors(qw(sth));
15  
16 # Define functions and class methods lest they be handled by AUTOLOAD, because
17 # there's no $self->sth to forward anything on in those cases.
18 0 ▶sub DEFAULTS { () }
Subroutine DEFAULTS: not called CC=1 SCAR=6.9
Pod documented
19 0 ▶sub FIRST_CONSTRUCTOR_ARGS { () }
Subroutine FIRST_CONSTRUCTOR_ARGS: not called CC=1 SCAR=6.9
Pod documented
20 0 ▶sub DESTROY { }
Subroutine DESTROY: not called CC=1 SCAR=0.0
21  
22 # Most methods are forwarded onto the statement handle, except for the ones
23 # handled differently below.
24 0 ▶sub AUTOLOAD {
Subroutine AUTOLOAD: not called CC=1 SCAR=2.6
25 0 (my $method = our $AUTOLOAD) =~ s/.*://;
26 6 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 0 ▶ *$AUTOLOAD = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
28 0 my $self = shift;
29  
30 # This package is just a wrapper, so report where the call came from
31 0 local $Error::Depth = $Error::Depth + 1;
32 0 $self->sth->$method(@_);
33 0 };
34 0 goto &$AUTOLOAD;
35 }
36  
37 # Stringify potential value objects.
38 0 ▶sub bind_param {
Subroutine bind_param: not called CC=1 SCAR=6.9
Pod documented
39 0 my ($self, @args) = @_;
40 0 $args[1] = value_of $args[1];
41  
42 # This package is just a wrapper, so report where the call came from
43 0 local $Error::Depth = $Error::Depth + 1;
44 0 $self->sth->bind_param(@args);
45 }
46  
47 # If we are given a value object, redirect the binding to the value object's
48 # internal value directly.
49 0 ▶sub bind_param_inout {
Subroutine bind_param_inout: not called CC=4 SCAR=30.0
Pod documented
50 0 my ($self, @args) = @_;
51 0 my $result = ${ $args[1] };
52 0 ▶ if (ref $result && UNIVERSAL::isa($result, 'Class::Value')) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $result and UNIVERSAL::isa($result, "Class::Value")) 0 0 0
Condition0%0/3
ref $result and UNIVERSAL::isa($result, "Class::Value")
!ll&&!rl&&r
000
MC/DC0%0/2
ref $result and UNIVERSAL::isa($result, "Class::Value")
ref $result UNIVERSAL::isa($result, "Class::Value")
Truth table0%0/3
A and B
A= ref $resultB= UNIVERSAL::isa($result, "Class::Value")
ABresult
0X0
100
111
53 0 ▶ $result->{_value} = undef unless exists $result->{_value};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $result->{"_value"} 0 0 0
54 0 $args[1] = \$result->{_value};
55 }
56  
57 # This package is just a wrapper, so report where the call came from
58 0 local $Error::Depth = $Error::Depth + 1;
59 0 $self->sth->bind_param_inout(@args);
60 }
61  
62 0 ▶sub Statement {
Subroutine Statement: not called CC=2 SCAR=17.9
Pod documented
63 0 my $self = shift;
64 0 ▶ return $self->sth->{Statement} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
65 0 $self->sth->{Statement} = $_[0];
66 }
67 6 1;
68  
69  
70 __END__
« Storage/DBI.pm ↑ Summary Storage/DBI/SQLite.pm »