Module: Torque::PostgreSQL::Relation::AuxiliaryStatement
- Included in:
- Torque::PostgreSQL::Relation
- Defined in:
- lib/torque/postgresql/relation/auxiliary_statement.rb
Instance Attribute Summary collapse
-
#auxiliary_statements ⇒ Object
Returns the value of attribute auxiliary_statements.
Instance Method Summary collapse
-
#bound_attributes ⇒ Object
Get all auxiliary statements bound attributes and the base bound attributes as well.
-
#with(*args) ⇒ Object
Set use of an auxiliary statement already configurated on the model.
-
#with!(*args) ⇒ Object
Like #with, but modifies relation in place.
Instance Attribute Details
#auxiliary_statements ⇒ Object
Returns the value of attribute auxiliary_statements.
6 7 8 |
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 6 def auxiliary_statements @auxiliary_statements end |
Instance Method Details
#bound_attributes ⇒ Object
Get all auxiliary statements bound attributes and the base bound attributes as well
28 29 30 31 32 |
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 28 def bound_attributes return super unless self.auxiliary_statements.present? bindings = self.auxiliary_statements.values.map(&:bound_attributes) (bindings + super).flatten end |
#with(*args) ⇒ Object
Set use of an auxiliary statement already configurated on the model
9 10 11 |
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 9 def with(*args) spawn.with!(*args) end |
#with!(*args) ⇒ Object
Like #with, but modifies relation in place.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/torque/postgresql/relation/auxiliary_statement.rb', line 14 def with!(*args) = args. self.auxiliary_statements ||= {} args.each do |table| instance = instantiate(table, self, ) instance.ensure_dependencies!(self) self.auxiliary_statements[table] = instance end self end |