File Coverage

blib/lib/SQL/Maker/SQLType.pm
Criterion Covered Total %
statement 27 28 96.4
branch 3 4 75.0
condition n/a
subroutine 10 10 100.0
pod 0 6 0.0
total 40 48 83.3


line stmt bran cond sub pod time code
1             package SQL::Maker::SQLType;
2 3     3   79140 use strict;
  3         7  
  3         112  
3 3     3   15 use warnings;
  3         6  
  3         78  
4 3     3   3112 use utf8;
  3         31  
  3         16  
5 3     3   121 use Exporter qw/import/;
  3         7  
  3         1005  
6              
7             our @EXPORT_OK = qw/sql_type/;
8              
9             sub sql_type {
10 9     9 0 14396 my ($value_ref, $type) = @_;
11 9         58 SQL::Maker::SQLType->new(value_ref => $value_ref, type => $type);
12             }
13              
14             sub new {
15 9     9 0 19 my $class = shift;
16 9 50       50 my %args = @_==1 ? %{$_[0]} : @_;
  0         0  
17 9         122 bless {%args}, $class;
18             }
19              
20 1     1 0 933 sub value_ref { $_[0]->{value_ref} }
21 1     1 0 6 sub type { $_[0]->{type} }
22              
23             sub as_sql {
24 3     3 0 32 my ($self, $supplied_colname, $quote_cb) = @_;
25 3         6 my $stmt;
26 3 100       8 if (defined $supplied_colname) {
27 2         8 $stmt = $quote_cb->($supplied_colname) . ' = ?';
28             } else {
29 1         3 $stmt = '?';
30             }
31 3         16 return $stmt;
32             }
33              
34             sub bind {
35 3     3 0 32 my $self = shift;
36 3         14 return $self;
37             }
38              
39             1;
40             __END__