Module: DeepPluck::DataCombiner

Defined in:
lib/deep_pluck/data_combiner.rb

Class Method Summary collapse

Class Method Details

.combine_data(parent, children, primary_key, column_name, foreign_key, reverse, collection) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/deep_pluck/data_combiner.rb', line 6

def combine_data(parent, children, primary_key, column_name, foreign_key, reverse, collection)
  source =  reverse ? parent : children
  target = !reverse ? parent : children
  data_hash = make_data_hash(collection, source, primary_key, column_name, reverse)
  assign_values_to_parent(collection, target, data_hash, column_name, foreign_key, reverse: reverse)
  return children
end