class ROM::Associations::OneToMany
Abstract
one-to-many association
@api public
Public Instance Methods
associate(child, parent)
click to toggle source
Associate child tuple with a parent
@param [Hash] child The child tuple @param [Hash] parent The parent tuple
@return [Hash]
@api private
# File lib/rom/associations/one_to_many.rb, line 37 def associate(child, parent) pk, fk = join_key_map child.merge(fk => parent.fetch(pk)) end
call(*)
click to toggle source
Adapters must implement this method
@abstract
@api public
# File lib/rom/associations/one_to_many.rb, line 16 def call(*) raise NotImplementedError end
foreign_key()
click to toggle source
Return configured or inferred FK name
@return [Symbol]
@api public
# File lib/rom/associations/one_to_many.rb, line 25 def foreign_key definition.foreign_key || target.foreign_key(source.name) end
Protected Instance Methods
source_key()
click to toggle source
Return primary key on the source side
@return [Symbol]
@api protected
# File lib/rom/associations/one_to_many.rb, line 49 def source_key source.schema.primary_key_name end
target_key()
click to toggle source
Return foreign key name on the target side
@return [Symbol]
@api protected
# File lib/rom/associations/one_to_many.rb, line 58 def target_key foreign_key end