Module: ROM::Plugins::Relation::SQL::AutoCombine::InstanceInterface
- Defined in:
- lib/rom/plugins/relation/sql/auto_combine.rb
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
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rom/plugins/relation/sql/auto_combine.rb', line 31 def for_combine(spec) source_key, target_key, target = case spec when ROM::SQL::Association [*spec.join_keys(__registry__).flatten, spec.call(__registry__)] 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.
44 45 46 |
# File 'lib/rom/plugins/relation/sql/auto_combine.rb', line 44 def preload(source_key, target_key, source) where(target_key => source.pluck(source_key.to_sym)) end |