Class: SqlQueryExecutor::Operators::Is

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

Instance Method Summary collapse

Constructor Details

#initialize(query, collection) ⇒ Is

Returns a new instance of Is.



6
7
8
9
# File 'lib/sql_query_executor/operators/is.rb', line 6

def initialize(query, collection)
  super
  convert_operator
end

Instance Method Details

#execute!Object



11
12
13
14
15
16
17
# File 'lib/sql_query_executor/operators/is.rb', line 11

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

    value.send(@operator, @value)
  end
end

#selectorObject



19
20
21
# File 'lib/sql_query_executor/operators/is.rb', line 19

def selector
  @operator == '==' ? { @field => @value } : { @field => {'$ne' => @value} }
end