Class: Transproc::ArrayTransformations::Combine

Inherits:
Object
  • Object
show all
Defined in:
lib/transproc/array/combine.rb

Constant Summary collapse

EMPTY_ARRAY =
[].freeze

Class Method Summary collapse

Class Method Details

.combine(array, mappings) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/transproc/array/combine.rb', line 9

def combine(array, mappings)
  root, nodes = array
  return EMPTY_ARRAY if root.nil?
  return root if nodes.nil?
  groups = group_nodes(nodes, mappings)

  root.map do |element|
    element.dup.tap { |copy| add_groups_to_element(copy, groups, mappings) }
  end
end