Class: ActiveRecord::Refined::AST::Value

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

Overview

A literal standing where an expression would: select { value(0).as(:depth) }.

Values reach the SQL quoted wherever they appear as an operand, but a bare Ruby literal at the top of a select list is refused as saying nothing. value is the spelling that quotes it there, and it carries the predications with it, so a literal can be compared and combined like anything else.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Arithmetics

#&, #*, #+, #-, #/, #<<, #>>, #^, #|, #~

Methods included from Predications

#!=, #!~, #<, #<=, #==, #=~, #>, #>=, #between?, #bury, #casecmp?, #contains?, #dig, #dig_text, #distinct_from?, #end_with?, #except, #false?, #ilike?, #in?, #include?, #intersect?, #key?, #keys, #like?, #member?, #not_between?, #not_distinct_from?, #not_false?, #not_ilike?, #not_in?, #not_like?, #not_null?, #not_true?, #null?, #start_with?, #subset?, #superset?, #true?, #when

Methods inherited from Node

#as, #asc, #collate, #desc

Constructor Details

#initialize(value) ⇒ Value

Returns a new instance of Value.



673
674
675
# File 'lib/active_record/refined/ast.rb', line 673

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



671
672
673
# File 'lib/active_record/refined/ast.rb', line 671

def value
  @value
end

Instance Method Details

#to_arel(_table, _model) ⇒ Object



677
678
679
# File 'lib/active_record/refined/ast.rb', line 677

def to_arel(_table, _model)
  Arel::Nodes.build_quoted(value)
end