Class: SqlQueryExecutor::Operators::Between

Inherits:
Base
  • Object
show all
Defined in:
lib/sql_query_executor/operators/between.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SqlQueryExecutor::Operators::Base

Instance Method Details

#execute!(result) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/sql_query_executor/operators/between.rb', line 6

def execute!(result)
  @collection.select do |record|
    value = convert_value(record.send(@field).to_s)

    if value.class != @value.first.class
      false
    else
      greather_than = value.send('>=', @value.first)
      smaller_than  = value.send('<=', @value.last)

      greather_than && smaller_than
    end
  end
end