Class: Arel::Nodes::Fragments

Inherits:
Node show all
Defined in:
activerecord/lib/arel/nodes/fragments.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#and, #equality?, #fetch_attribute, #invert, #not, #or, #to_sql

Methods included from FactoryMethods

#cast, #coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower

Constructor Details

#initialize(values = []) ⇒ Fragments

Returns a new instance of Fragments.



8
9
10
11
# File 'activerecord/lib/arel/nodes/fragments.rb', line 8

def initialize(values = [])
  super()
  @values = values
end

Instance Attribute Details

#valuesObject (readonly)

Returns the value of attribute values.



6
7
8
# File 'activerecord/lib/arel/nodes/fragments.rb', line 6

def values
  @values
end

Instance Method Details

#+(other) ⇒ Object

Raises:

  • (ArgumentError)


22
23
24
25
26
# File 'activerecord/lib/arel/nodes/fragments.rb', line 22

def +(other)
  raise ArgumentError, "Expected Arel node" unless Arel.arel_node?(other)

  self.class.new([*@values, other])
end

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


28
29
30
31
# File 'activerecord/lib/arel/nodes/fragments.rb', line 28

def eql?(other)
  self.class == other.class &&
    self.values == other.values
end

#hashObject



18
19
20
# File 'activerecord/lib/arel/nodes/fragments.rb', line 18

def hash
  [@values].hash
end

#initialize_copy(other) ⇒ Object



13
14
15
16
# File 'activerecord/lib/arel/nodes/fragments.rb', line 13

def initialize_copy(other)
  super
  @values = @values.clone
end