Class: ActiveRecord::Refined::AST::Node

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

Instance Method Summary collapse

Instance Method Details

#as(alias_name, quote: true) ⇒ Object



399
400
401
# File 'lib/active_record/refined/ast.rb', line 399

def as(alias_name, quote: true)
  As.new(self, alias_name, quote: quote)
end

#ascObject



403
404
405
# File 'lib/active_record/refined/ast.rb', line 403

def asc
  Ordering.new(self, :asc)
end

#descObject



407
408
409
# File 'lib/active_record/refined/ast.rb', line 407

def desc
  Ordering.new(self, :desc)
end

#to_arel(table, model) ⇒ Object

The model travels with the table because some SQL cannot be written without knowing the adapter, and a node is built before anything knows which one it will be rendered for -- a symbol becomes a node inside a refinement, where there is no model to ask. Most nodes never look at it and only pass it on.

Raises:

  • (ScriptError)


395
396
397
# File 'lib/active_record/refined/ast.rb', line 395

def to_arel(table, model)
  raise ScriptError, "subclass must override this method"
end