Class: MongoModel::MongoOperator
- Inherits:
-
Object
- Object
- MongoModel::MongoOperator
- Defined in:
- lib/mongomodel/support/mongo_operator.rb
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
Returns the value of attribute field.
-
#operator ⇒ Object
readonly
Returns the value of attribute operator.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(field, operator) ⇒ MongoOperator
constructor
A new instance of MongoOperator.
- #inspect ⇒ Object
- #to_mongo_selector(value) ⇒ Object
Constructor Details
#initialize(field, operator) ⇒ MongoOperator
Returns a new instance of MongoOperator.
5 6 7 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 5 def initialize(field, operator) @field, @operator = field, operator end |
Instance Attribute Details
#field ⇒ Object (readonly)
Returns the value of attribute field.
3 4 5 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 3 def field @field end |
#operator ⇒ Object (readonly)
Returns the value of attribute operator.
3 4 5 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 3 def operator @operator end |
Instance Method Details
#==(other) ⇒ Object
17 18 19 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 17 def ==(other) other.is_a?(self.class) && field == other.field && operator == other.operator end |
#eql?(other) ⇒ Boolean
25 26 27 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 25 def eql?(other) self == other end |
#hash ⇒ Object
21 22 23 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 21 def hash field.hash ^ operator.hash end |
#inspect ⇒ Object
13 14 15 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 13 def inspect "#{field.inspect}.#{operator}" end |
#to_mongo_selector(value) ⇒ Object
9 10 11 |
# File 'lib/mongomodel/support/mongo_operator.rb', line 9 def to_mongo_selector(value) { "$#{operator}" => value } end |