Class: ActiveRecord::Refined::AST::Aggregate

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, function) ⇒ Aggregate

Returns a new instance of Aggregate.



64
65
66
67
# File 'lib/active_record/refined/ast.rb', line 64

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

Instance Attribute Details

#functionObject (readonly)

Returns the value of attribute function.



62
63
64
# File 'lib/active_record/refined/ast.rb', line 62

def function
  @function
end

#operandObject (readonly)

Returns the value of attribute operand.



62
63
64
# File 'lib/active_record/refined/ast.rb', line 62

def operand
  @operand
end

Instance Method Details

#to_arel(table) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/active_record/refined/ast.rb', line 69

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