Class: Squeel::Nodes::Literal

Inherits:
Node
  • Object
show all
Includes:
Aliasing, Operators, Ordering, PredicateMethods, PredicateOperators
Defined in:
lib/squeel/nodes/literal.rb

Overview

Literal nodes are a container for raw SQL.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Ordering

#asc, #desc

Methods included from Aliasing

#as

Methods included from Operators

#*, #+, #-, #/, #op

Methods included from PredicateOperators

#&, #-@, #|

Methods included from PredicateMethods

#eq

Methods inherited from Node

#each, #grep

Constructor Details

#initialize(expr) ⇒ Literal



13
14
15
# File 'lib/squeel/nodes/literal.rb', line 13

def initialize(expr)
  @expr = expr
end

Instance Attribute Details

#exprObject (readonly)

Returns the value of attribute expr



11
12
13
# File 'lib/squeel/nodes/literal.rb', line 11

def expr
  @expr
end

Instance Method Details

#eql?(other) ⇒ Boolean

Object comparison



30
31
32
33
# File 'lib/squeel/nodes/literal.rb', line 30

def eql?(other)
  self.class.eql?(other.class) &&
  self.expr.eql?(other.expr)
end

#hashObject

To support object equality tests



36
37
38
# File 'lib/squeel/nodes/literal.rb', line 36

def hash
  expr.hash
end

#to_sString Also known as: to_str



49
50
51
# File 'lib/squeel/nodes/literal.rb', line 49

def to_s
  expr.to_s
end

#to_symNilClass

expand_hash_conditions_for_aggregates assumes our hash keys can be converted to symbols, so this has to be implemented, but it doesn't really have to do anything useful.



44
45
46
# File 'lib/squeel/nodes/literal.rb', line 44

def to_sym
  nil
end