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, #desc

Constructor Details

#initialize(value) ⇒ Value

Returns a new instance of Value.



495
496
497
# File 'lib/active_record/refined/ast.rb', line 495

def initialize(value)
  @value = value
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



493
494
495
# File 'lib/active_record/refined/ast.rb', line 493

def value
  @value
end

Instance Method Details

#to_arel(_table, _model) ⇒ Object



499
500
501
# File 'lib/active_record/refined/ast.rb', line 499

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