Class: SymbolOperator

Inherits:
Object show all
Defined in:
lib/mongo_mapper/support.rb

Instance Method Summary collapse

Constructor Details

#initialize(field, operator, options = {}) ⇒ SymbolOperator

Returns a new instance of SymbolOperator.



167
168
169
# File 'lib/mongo_mapper/support.rb', line 167

def initialize(field, operator, options={})
  @field, @operator = field, operator
end

Instance Method Details

#to_mm_criteria(value) ⇒ Object



171
172
173
# File 'lib/mongo_mapper/support.rb', line 171

def to_mm_criteria(value)
  {MongoMapper::FinderOptions.normalized_field(@field) => {"$#{@operator}" => value}}
end

#to_mm_orderObject



175
176
177
# File 'lib/mongo_mapper/support.rb', line 175

def to_mm_order
  [@field.to_s, MongoMapper::FinderOptions.normalized_order_direction(@operator)]
end