Class: ActiveRecord::Refined::AST::As

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, alias_name) ⇒ As

Returns a new instance of As.



85
86
87
88
# File 'lib/active_record/refined/ast.rb', line 85

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

Instance Attribute Details

#alias_nameObject (readonly)

Returns the value of attribute alias_name.



83
84
85
# File 'lib/active_record/refined/ast.rb', line 83

def alias_name
  @alias_name
end

#operandObject (readonly)

Returns the value of attribute operand.



83
84
85
# File 'lib/active_record/refined/ast.rb', line 83

def operand
  @operand
end

Instance Method Details

#to_arel(table) ⇒ Object



90
91
92
93
94
95
96
97
# File 'lib/active_record/refined/ast.rb', line 90

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.as(alias_name.to_s)
end