class ROM::Associations::ManyToOne
Abstract
many-to-one association type
@api public
Public Instance Methods
associate(child, parent)
click to toggle source
Associate child with a parent
@param [Hash] child The child tuple @param [Hash] parent The parent tuple
@return [Hash]
@api private
# File lib/rom/associations/many_to_one.rb, line 37 def associate(child, parent) fk, pk = 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/many_to_one.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/many_to_one.rb, line 25 def foreign_key definition.foreign_key || source.foreign_key(target.name) end
Protected Instance Methods
source_key()
click to toggle source
Return foreign key on the source side
@return [Symbol]
@api protected
# File lib/rom/associations/many_to_one.rb, line 49 def source_key foreign_key end
target_key()
click to toggle source
Return primary key on the target side
@return [Symbol]
@api protected
# File lib/rom/associations/many_to_one.rb, line 58 def target_key target.schema.primary_key_name end