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

Constant Summary

Constants included from Memoizable

Memoizable::MEMOIZED_HASH

Instance Attribute Summary

Attributes inherited from Abstract

#definition, #relations, #source, #target

Attributes included from Memoizable

#__memoized__

Instance Method Summary collapse

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

extended

Methods included from Memoizable

included

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)


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

#callObject

This method is abstract.

Adapters must implement this method

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/rom/associations/one_to_many.rb', line 14

def call(*)
  raise NotImplementedError
end

#foreign_keySymbol

Return configured or inferred FK name

Returns:

  • (Symbol)


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