Class: MongoModel::MongoOperator

Inherits:
Object
  • Object
show all
Defined in:
lib/mongomodel/support/mongo_operator.rb

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (MongoOperator) initialize(field, operator)



5
6
7
# File 'lib/mongomodel/support/mongo_operator.rb', line 5

def initialize(field, operator)
  @field, @operator = field, operator
end

Instance Attribute Details

- (Object) field (readonly)

Returns the value of attribute field



3
4
5
# File 'lib/mongomodel/support/mongo_operator.rb', line 3

def field
  @field
end

- (Object) operator (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

- (Object) ==(other)



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

- (Boolean) eql?(other)



25
26
27
# File 'lib/mongomodel/support/mongo_operator.rb', line 25

def eql?(other)
  self == other
end

- (Object) hash



21
22
23
# File 'lib/mongomodel/support/mongo_operator.rb', line 21

def hash
  field.hash ^ operator.hash
end

- (Object) inspect



13
14
15
# File 'lib/mongomodel/support/mongo_operator.rb', line 13

def inspect
  "#{field.inspect}.#{operator}"
end

- (Object) to_mongo_selector(value)



9
10
11
# File 'lib/mongomodel/support/mongo_operator.rb', line 9

def to_mongo_selector(value)
  { "$#{operator}" => value }
end