Module: ROM::SQL::Associations::Core Private

Included in:
ManyToMany, ManyToOne, OneToMany
Defined in:
lib/rom/sql/associations/core.rb

Overview

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.

Core SQL association API

Instance Method Summary collapse

Instance Method Details

#preload(target, loaded) ⇒ Object

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.


11
12
13
14
15
16
17
18
# File 'lib/rom/sql/associations/core.rb', line 11

def preload(target, loaded)
  source_key, target_key = join_keys.flatten(1)

  target_pks = loaded.pluck(source_key.key)
  target_pks.uniq!

  target.where(target_key => target_pks)
end

#wrappedObject

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.


21
22
23
24
25
26
# File 'lib/rom/sql/associations/core.rb', line 21

def wrapped
  new_target = view ? target.send(view) : target
  to_wrap = self.class.allocate
  to_wrap.send(:initialize, definition, **options, target: new_target)
  to_wrap.wrap
end