Class: ActiveRecord::Refined::AST::Function

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(name, args) ⇒ Function

Returns a new instance of Function.



121
122
123
124
# File 'lib/active_record/refined/ast.rb', line 121

def initialize(name, args)
  @name = name
  @args = args
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



119
120
121
# File 'lib/active_record/refined/ast.rb', line 119

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



119
120
121
# File 'lib/active_record/refined/ast.rb', line 119

def name
  @name
end

Instance Method Details

#to_arel(table) ⇒ Object



126
127
128
129
130
131
132
133
134
135
# File 'lib/active_record/refined/ast.rb', line 126

def to_arel(table)
  arel_args = args.map do |arg|
    case arg
    when Node then arg.to_arel(table)
    when Symbol then table[arg]
    else Arel::Nodes.build_quoted(arg)
    end
  end
  Arel::Nodes::NamedFunction.new(name, arel_args)
end