Module: ROM::SQL::Plugin::Associates::InstanceMethods Private

Defined in:
lib/rom/sql/plugin/associates.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Instance Method Details

#SQL::Commands::CreateArray<Hash>, Hash

Set fk on tuples from parent tuple

Parameters:

  • tuples (Array<Hash>, Hash)

    The input tuple(s)

  • parent (Hash)

    The parent tuple with its pk already set

Returns:

  • (Array<Hash>, Hash)


25
26
27
28
29
30
31
32
33
# File 'lib/rom/sql/plugin/associates.rb', line 25

def execute(tuples, parent)
  fk, pk = association[:key]

  input_tuples = with_input_tuples(tuples).map { |tuple|
    tuple.merge(fk => parent.fetch(pk))
  }

  super(input_tuples)
end