File Coverage

blib/lib/DBIx/Romani/Query/Where.pm
Criterion Covered Total %
statement 3 29 10.3
branch 0 6 0.0
condition 0 3 0.0
subroutine 1 7 14.2
pod 0 6 0.0
total 4 51 7.8


line stmt bran cond sub pod time code
1              
2             package DBIx::Romani::Query::Where;
3              
4 1     1   5 use strict;
  1         1  
  1         383  
5              
6             our $AND = 'AND';
7             our $OR = 'OR';
8              
9             sub new
10             {
11 0     0 0   my $class = shift;
12 0           my $args = shift;
13              
14 0           my $type;
15              
16 0 0         if ( ref($args) eq 'HASH' )
17             {
18 0           $type = $args->{type};
19             }
20             else
21             {
22 0           $type = $args;
23             }
24              
25 0 0         if ( not defined $type )
26             {
27 0           $type = $AND;
28             }
29              
30 0 0 0       if ( $type ne $AND and $type ne $OR )
31             {
32 0           die "Invalid SQL group type";
33             }
34              
35 0           my $self = {
36             type => $type,
37             values => [ ],
38             };
39              
40 0           bless $self, $class;
41 0           return $self;
42             }
43              
44 0     0 0   sub get_type { return shift->{type}; }
45 0     0 0   sub get_values { return shift->{values}; }
46              
47             sub add
48             {
49 0     0 0   my ($self, $val) = @_;
50 0           push @{$self->{values}}, $val;
  0            
51             }
52              
53             sub visit
54             {
55 0     0 0   my ($self, $visitor) = (shift, shift);
56 0           return $visitor->visit_where( $self, @_ );
57             }
58              
59             sub clone
60             {
61 0     0 0   my $self = shift;
62              
63 0           my $clone = DBIx::Romani::Query::Where->new({ type => $self->get_type() });
64 0           foreach my $value ( @{$self->get_values()} )
  0            
65             {
66 0           $clone->add( $value );
67             }
68            
69 0           return $clone;
70             }
71              
72             1;
73