Class: SqlQueryExecutor::Operators::Between
- Inherits:
-
Base
- Object
- Base
- SqlQueryExecutor::Operators::Between
show all
- Defined in:
- lib/sql_query_executor/operators/between.rb
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#execute! ⇒ 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!
@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
|
#selector ⇒ Object
21
22
23
|
# File 'lib/sql_query_executor/operators/between.rb', line 21
def selector
{ @field => { "$gte" => @value.first, "$lte" => @value.last }}
end
|