Module: ROM::Plugins::Relation::SQL::AutoWrap::InstanceInterface Private

Defined in:
lib/rom/plugins/relation/sql/auto_wrap.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#for_wrap(keys, name) ⇒ SQL::Relation

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Default methods for fetching wrapped relation

This method is used by default by ‘wrap` and `wrap_parents`

Returns:



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rom/plugins/relation/sql/auto_wrap.rb', line 34

def for_wrap(keys, name)
  rel, other =
    if associations.key?(name)
      assoc = associations[name]
      other = __registry__[assoc.target.to_sym]

      [assoc.join(__registry__, :inner_join, self), other]
    else
      # TODO: deprecate this before 2.0
      other = __registry__[name]
      other_dataset = other.name.dataset

      [qualified.inner_join(other_dataset, keys), other]
    end

  rel.schema.merge(other.schema.wrap).qualified.(rel)
end