Class: ActiveRecord::Refined::AST::Ordering

Inherits:
Node
  • Object
show all
Defined in:
lib/active_record/refined/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#as, #asc, #desc

Constructor Details

#initialize(operand, direction) ⇒ Ordering

Returns a new instance of Ordering.



103
104
105
106
# File 'lib/active_record/refined/ast.rb', line 103

def initialize(operand, direction)
  @operand = operand
  @direction = direction
end

Instance Attribute Details

#directionObject (readonly)

Returns the value of attribute direction.



101
102
103
# File 'lib/active_record/refined/ast.rb', line 101

def direction
  @direction
end

#operandObject (readonly)

Returns the value of attribute operand.



101
102
103
# File 'lib/active_record/refined/ast.rb', line 101

def operand
  @operand
end

Instance Method Details

#to_arel(table) ⇒ Object



108
109
110
111
112
113
114
115
# File 'lib/active_record/refined/ast.rb', line 108

def to_arel(table)
  arel_operand = case operand
                 when Node then operand.to_arel(table)
                 when Symbol then table[operand]
                 else operand
                 end
  arel_operand.public_send(direction)
end