Class: ROM::Associations::OneToMany

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

Overview

Abstract one-to-many association

Direct Known Subclasses

OneToOne, Memory::Associations::OneToMany

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

Parameters:

  • child (Hash)

    The child tuple

  • parent (Hash)

    The parent tuple

Returns:

  • (Hash)

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

#callObject

This method is abstract.

Adapters must implement this method

Raises:

  • (NotImplementedError)

16
17
18
# File 'lib/rom/associations/one_to_many.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/one_to_many.rb', line 25

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