Class: Mongoid::Criterion::Complex

Inherits:
Object
  • Object
show all
Defined in:
lib/mongoid_location/criterion/complex.rb

Overview

Complex criterion are used when performing operations on symbols to get get a shorthand syntax for where clauses.

Example:

{ :field => { "$lt" => "value" } } becomes: { :field.lt => "value }

Direct Known Subclasses

NearSpatial, WithinSpatial

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Complex

Returns a new instance of Complex.



16
17
18
# File 'lib/mongoid_location/criterion/complex.rb', line 16

def initialize(opts = {})
  @key, @operator = opts[:key], opts[:operator]
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



14
15
16
# File 'lib/mongoid_location/criterion/complex.rb', line 14

def key
  @key
end

#operatorObject

Returns the value of attribute operator.



14
15
16
# File 'lib/mongoid_location/criterion/complex.rb', line 14

def operator
  @operator
end

Instance Method Details

#to_mongo_query(v) ⇒ Object



20
21
22
# File 'lib/mongoid_location/criterion/complex.rb', line 20

def to_mongo_query v
  {"$#{operator}" => v}
end