Class: ActiveRecord::Refined::AST::As
- Defined in:
- lib/active_record/refined/ast.rb
Instance Attribute Summary collapse
-
#alias_name ⇒ Object
readonly
Returns the value of attribute alias_name.
-
#operand ⇒ Object
readonly
Returns the value of attribute operand.
Instance Method Summary collapse
-
#initialize(operand, alias_name) ⇒ As
constructor
A new instance of As.
- #to_arel(table) ⇒ Object
Methods inherited from Node
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_name ⇒ Object (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 |
#operand ⇒ Object (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 |