Module: Torque::PostgreSQL::Relation::AuxiliaryStatement

Defined in:
lib/torque/postgresql/relation/auxiliary_statement.rb

Instance Method Summary collapse

Instance Method Details

#auxiliary_statements_valuesObject

:nodoc:



9
10
11
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 9

def auxiliary_statements_values
  @values.fetch(:auxiliary_statements, FROZEN_EMPTY_ARRAY)
end

#auxiliary_statements_values=(value) ⇒ Object

:nodoc:



13
14
15
16
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 13

def auxiliary_statements_values=(value)
  assert_modifiable!
  @values[:auxiliary_statements] = value
end

#bound_attributesObject

Get all auxiliary statements bound attributes and the base bound attributes as well



34
35
36
37
38
39
40
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 34

def bound_attributes
  visitor = ::Arel::Visitors::PostgreSQL.new(ActiveRecord::Base.connection)
  visitor.accept(self.arel.ast, ::Arel::Collectors::Composite.new(
    ::Arel::Collectors::SQLString.new,
    ::Arel::Collectors::Bind.new,
  )).value.last
end

#with(*args, **settings) ⇒ Object Also known as: auxiliary_statements

Set use of an auxiliary statement



19
20
21
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 19

def with(*args, **settings)
  spawn.with!(*args, **settings)
end

#with!(*args, **settings) ⇒ Object Also known as: auxiliary_statements!

Like #with, but modifies relation in place.



24
25
26
27
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 24

def with!(*args, **settings)
  instantiate_auxiliary_statements(*args, **settings)
  self
end