File Coverage

lib/DBIx/ActiveRecord/Arel/Where.pm
Criterion Covered Total %
statement 20 20 100.0
branch 4 4 100.0
condition 6 6 100.0
subroutine 7 7 100.0
pod 0 5 0.0
total 37 42 88.1


line stmt bran cond sub pod time code
1             package DBIx::ActiveRecord::Arel::Where;
2 2     2   10 use strict;
  2         2  
  2         62  
3 2     2   9 use warnings;
  2         4  
  2         837  
4              
5             sub new {
6 37     37 0 58 my ($self, $operator, $column, $value) = @_;
7 37         210 bless {op => $operator, column => $column, value => $value}, $self;
8             }
9              
10 173     173 0 564 sub op {shift->{op}}
11 37     37 0 95 sub column_name {shift->{column}->name}
12 70     70 0 188 sub value {shift->{value}}
13              
14             sub build {
15 37     37 0 35 my $self = shift;
16 37         36 my $where;
17             my @binds;
18 37 100 100     50 if ($self->op eq 'IN' || $self->op eq 'NOT IN') {
    100 100        
19 4         9 $where = $self->column_name.' '.$self->op.' ('.$self->value->placeholder.')';
20 4         10 push @binds, $self->value->binds;
21             } elsif ($self->op eq 'IS NULL' || $self->op eq 'IS NOT NULL') {
22 2         5 $where = $self->column_name.' '.$self->op;
23             } else {
24 31         80 $where = $self->column_name.' '. $self->op.' '.$self->value->placeholder;
25 31         64 push @binds, $self->value->binds;
26             }
27 37         120 return ($where, \@binds);
28             }
29              
30             1;