Class: Activecube::Query::Selector::Operator
- Inherits:
-
Object
- Object
- Activecube::Query::Selector::Operator
- Defined in:
- lib/activecube/query/selector.rb
Instance Attribute Summary collapse
-
#argument ⇒ Object
readonly
Returns the value of attribute argument.
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #expression(_model, left, right) ⇒ Object
- #hash ⇒ Object
-
#initialize(operation, argument) ⇒ Operator
constructor
A new instance of Operator.
Constructor Details
#initialize(operation, argument) ⇒ Operator
Returns a new instance of Operator.
44 45 46 47 |
# File 'lib/activecube/query/selector.rb', line 44 def initialize operation, argument @operation = operation @argument = argument end |
Instance Attribute Details
#argument ⇒ Object (readonly)
Returns the value of attribute argument.
42 43 44 |
# File 'lib/activecube/query/selector.rb', line 42 def argument @argument end |
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
42 43 44 |
# File 'lib/activecube/query/selector.rb', line 42 def operation @operation end |
Instance Method Details
#==(other) ⇒ Object
63 64 65 |
# File 'lib/activecube/query/selector.rb', line 63 def == other eql? other end |
#eql?(other) ⇒ Boolean
57 58 59 60 61 |
# File 'lib/activecube/query/selector.rb', line 57 def eql?(other) return other.kind_of?(Operator) && self.operation==other.operation && self.argument == other.argument end |
#expression(_model, left, right) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/activecube/query/selector.rb', line 49 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 |
#hash ⇒ Object
67 68 69 |
# File 'lib/activecube/query/selector.rb', line 67 def hash self.operation.hash + self.argument.hash end |