Module: Vorpal::AggregateUtils

Extended by:
AggregateUtils
Included in:
AggregateUtils
Defined in:
lib/vorpal/aggregate_utils.rb

Instance Method Summary collapse

Instance Method Details

#group_by_type(roots, configs) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vorpal/aggregate_utils.rb', line 8

def group_by_type(roots, configs)
  traversal = AggregateTraversal.new(configs)

  all = roots.flat_map do |root|
    owned_object_visitor = OwnedObjectVisitor.new
    traversal.accept(root, owned_object_visitor)
    owned_object_visitor.owned_objects
  end

  all.group_by { |obj| configs.config_for(obj.class) }
end