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



307
308
309
# File 'lib/active_record/refined/ast.rb', line 307

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

#ascObject



311
312
313
# File 'lib/active_record/refined/ast.rb', line 311

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

#descObject



315
316
317
# File 'lib/active_record/refined/ast.rb', line 315

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)


303
304
305
# File 'lib/active_record/refined/ast.rb', line 303

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