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?, #null?, #start_with?

Methods inherited from Node

#as, #asc, #desc

Constructor Details

#initialize(name, args) ⇒ Function

Returns a new instance of Function.



178
179
180
181
# File 'lib/active_record/refined/ast.rb', line 178

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

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



176
177
178
# File 'lib/active_record/refined/ast.rb', line 176

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



176
177
178
# File 'lib/active_record/refined/ast.rb', line 176

def name
  @name
end

Instance Method Details

#to_arel(table) ⇒ Object



183
184
185
186
187
188
189
190
191
# File 'lib/active_record/refined/ast.rb', line 183

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