Class: ROM::Associations::OneToMany
- Defined in:
- lib/rom/associations/one_to_many.rb
Overview
Abstract one-to-many association
Direct Known Subclasses
Constant Summary
Constants included from Memoizable
Instance Attribute Summary
Attributes inherited from Abstract
#definition, #relations, #source, #target
Attributes included from Memoizable
Instance Method Summary collapse
-
#associate(child, parent) ⇒ Hash
private
Associate child tuple with a parent.
-
#call ⇒ Object
abstract
Adapters must implement this method.
-
#foreign_key ⇒ Symbol
Return configured or inferred FK name.
Methods inherited from Abstract
#aliased?, #apply_view, #as, #combine_keys, #join_key_map, #key, #name, new, #node, #override?, #prepare, #result, #self_ref?, #view, #wrap
Methods included from Initializer
Methods included from Memoizable
Instance Method Details
#associate(child, parent) ⇒ Hash
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.
Associate child tuple with a parent
35 36 37 38 |
# File 'lib/rom/associations/one_to_many.rb', line 35 def associate(child, parent) pk, fk = join_key_map child.merge(fk => parent.fetch(pk)) end |
#call ⇒ Object
This method is abstract.
Adapters must implement this method
14 15 16 |
# File 'lib/rom/associations/one_to_many.rb', line 14 def call(*) raise NotImplementedError end |
#foreign_key ⇒ Symbol
Return configured or inferred FK name
23 24 25 |
# File 'lib/rom/associations/one_to_many.rb', line 23 def foreign_key definition.foreign_key || target.foreign_key(source.name) end |