Class: ROM::Associations::ManyToOne

Inherits:
Abstract
  • Object
show all
Defined in:
lib/rom/associations/many_to_one.rb

Overview

Abstract many-to-one association type

Direct Known Subclasses

Memory::Associations::ManyToOne

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#__memoized__Object (readonly) Originally defined in module Memoizable

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.

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 with a parent

Parameters:

  • child (Hash)

    The child tuple

  • parent (Hash)

    The parent tuple

Returns:

  • (Hash)


37
38
39
40
# 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

#callObject

This method is abstract.

Adapters must implement this method

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/rom/associations/many_to_one.rb', line 16

def call(*)
  raise NotImplementedError
end

#foreign_keySymbol

Return configured or inferred FK name

Returns:

  • (Symbol)


25
26
27
# File 'lib/rom/associations/many_to_one.rb', line 25

def foreign_key
  definition.foreign_key || source.foreign_key(target.name)
end