Class: Activecube::Query::Selector::Operator

Inherits:
Object
  • Object
show all
Defined in:
lib/activecube/query/selector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(operation, argument) ⇒ Operator

Returns a new instance of Operator.



49
50
51
52
# File 'lib/activecube/query/selector.rb', line 49

def initialize operation, argument
  @operation = operation
  @argument = argument
end

Instance Attribute Details

#argumentObject (readonly)

Returns the value of attribute argument.



47
48
49
# File 'lib/activecube/query/selector.rb', line 47

def argument
  @argument
end

#operationObject (readonly)

Returns the value of attribute operation.



47
48
49
# File 'lib/activecube/query/selector.rb', line 47

def operation
  @operation
end

Instance Method Details

#==(other) ⇒ Object



68
69
70
# File 'lib/activecube/query/selector.rb', line 68

def == other
  eql? other
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


62
63
64
65
66
# File 'lib/activecube/query/selector.rb', line 62

def eql?(other)
  return other.kind_of?(Operator) &&
      self.operation==other.operation &&
      self.argument == other.argument
end

#expression(_model, left, right) ⇒ Object



54
55
56
57
58
59
60
# File 'lib/activecube/query/selector.rb', line 54

def expression _model, left, right
  if right.kind_of?(Array) && (matching_array_op = ARRAY_OPERATOR_MAP[operation])
    left.send(matching_array_op, right)
  else
    left.send(operation, right)
  end
end

#hashObject



72
73
74
# File 'lib/activecube/query/selector.rb', line 72

def hash
  self.operation.hash + self.argument.hash
end