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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Predications

#!=, #!~, #<, #<=, #==, #=~, #>, #>=, #between?, #end_with?, #in?, #include?, #like?, #member?, #null?, #start_with?

Methods inherited from Node

#as, #asc, #desc

Constructor Details

#initialize(name, args) ⇒ Function

Returns a new instance of Function.



197
198
199
200
# File 'lib/active_record/refined/ast.rb', line 197

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



195
196
197
# File 'lib/active_record/refined/ast.rb', line 195

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



195
196
197
# File 'lib/active_record/refined/ast.rb', line 195

def name
  @name
end

Instance Method Details

#to_arel(table) ⇒ Object



202
203
204
205
206
207
208
209
210
# File 'lib/active_record/refined/ast.rb', line 202

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