Class: Squeel::Nodes::Literal
- Inherits:
-
Object
- Object
- Squeel::Nodes::Literal
- Includes:
- Aliasing, Operators, PredicateOperators, PredicateMethods
- Defined in:
- lib/squeel/nodes/literal.rb
Overview
Literal nodes are a container for raw SQL.
Instance Attribute Summary collapse
-
#expr ⇒ Object
readonly
Returns the value of attribute expr.
Instance Method Summary collapse
-
#asc ⇒ Order
Create an ascending Order node with this Literal as its expression.
-
#desc ⇒ Order
Create a descending Order node with this Literal as its expression.
-
#eql?(other) ⇒ Boolean
Object comparison.
-
#hash ⇒ Object
To support object equality tests.
-
#initialize(expr) ⇒ Literal
constructor
A new instance of Literal.
-
#to_s ⇒ String
(also: #to_str)
The Literal’s String equivalent.
-
#to_sym ⇒ NilClass
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.
Methods included from Aliasing
Methods included from Operators
Methods included from PredicateOperators
Constructor Details
#initialize(expr) ⇒ Literal
Returns a new instance of Literal.
16 17 18 |
# File 'lib/squeel/nodes/literal.rb', line 16 def initialize(expr) @expr = expr end |
Instance Attribute Details
#expr ⇒ Object (readonly)
Returns the value of attribute expr.
14 15 16 |
# File 'lib/squeel/nodes/literal.rb', line 14 def expr @expr end |
Instance Method Details
#asc ⇒ Order
Create an ascending Order node with this Literal as its expression
34 35 36 |
# File 'lib/squeel/nodes/literal.rb', line 34 def asc Order.new self, 1 end |
#desc ⇒ Order
Create a descending Order node with this Literal as its expression
40 41 42 |
# File 'lib/squeel/nodes/literal.rb', line 40 def desc Order.new self, -1 end |
#eql?(other) ⇒ Boolean
Object comparison
45 46 47 48 |
# File 'lib/squeel/nodes/literal.rb', line 45 def eql?(other) self.class.eql?(other.class) && self.expr.eql?(other.expr) end |
#hash ⇒ Object
To support object equality tests
51 52 53 |
# File 'lib/squeel/nodes/literal.rb', line 51 def hash expr.hash end |
#to_s ⇒ String Also known as: to_str
Returns The Literal’s String equivalent.
64 65 66 |
# File 'lib/squeel/nodes/literal.rb', line 64 def to_s expr.to_s end |
#to_sym ⇒ NilClass
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.
59 60 61 |
# File 'lib/squeel/nodes/literal.rb', line 59 def to_sym nil end |