Module: ROM::Plugins::Relation::SQL::AutoCombine::InstanceInterface Private
- Defined in:
- lib/rom/plugins/relation/sql/auto_combine.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
-
#for_combine(spec) ⇒ SQL::Relation
private
Default methods for fetching combined relation.
- #preload(source_key, target_key, source) ⇒ Object private
Instance Method Details
#for_combine(spec) ⇒ 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 combined relation
This method is used by default by ‘combine`
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rom/plugins/relation/sql/auto_combine.rb', line 35 def for_combine(spec) source_key, target_key, target = case spec when ROM::SQL::Association [*spec.join_keys(__registry__).flatten, spec.call(__registry__, self)] else [*spec.flatten, self] end target.preload(source_key, target_key) end |
#preload(source_key, target_key, source) ⇒ 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.
48 49 50 51 52 53 |
# File 'lib/rom/plugins/relation/sql/auto_combine.rb', line 48 def preload(source_key, target_key, source) target_pks = source.pluck(source_key.to_sym).uniq target_pks.uniq! where(target_key => target_pks) end |