Class: Mongoid::Criterion::Complex
- Defined in:
- lib/mongoid/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 }
Instance Attribute Summary collapse
-
#key ⇒ Object
Returns the value of attribute key.
-
#operator ⇒ Object
Returns the value of attribute operator.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(opts = {}) ⇒ Complex
constructor
Create the new complex criterion.
Constructor Details
#initialize(opts = {}) ⇒ Complex
Create the new complex criterion.
16 17 18 |
# File 'lib/mongoid/criterion/complex.rb', line 16 def initialize(opts = {}) @key, @operator = opts[:key], opts[:operator] end |
Instance Attribute Details
#key ⇒ Object
Returns the value of attribute key.
13 14 15 |
# File 'lib/mongoid/criterion/complex.rb', line 13 def key @key end |
#operator ⇒ Object
Returns the value of attribute operator.
13 14 15 |
# File 'lib/mongoid/criterion/complex.rb', line 13 def operator @operator end |
Instance Method Details
#==(other) ⇒ Object
28 29 30 31 |
# File 'lib/mongoid/criterion/complex.rb', line 28 def ==(other) return false unless other.is_a?(self.class) self.key == other.key && self.operator == other.operator end |
#eql?(other) ⇒ Boolean
24 25 26 |
# File 'lib/mongoid/criterion/complex.rb', line 24 def eql?(other) self == (other) end |
#hash ⇒ Object
20 21 22 |
# File 'lib/mongoid/criterion/complex.rb', line 20 def hash [@key, @operator].hash end |