Class: FactoryTrace::Preprocessors::ExtractUsed

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_trace/preprocessors/extract_used.rb

Class Method Summary collapse

Class Method Details

.call(trace) ⇒ FactoryTrace::Structures::Collection

Returns a collection with used factories and traits gathered from trace

Parameters:

  • (Hash<String, Set<String>>)

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/factory_trace/preprocessors/extract_used.rb', line 11

def self.call(trace)
  collection = FactoryTrace::Structures::Collection.new

  trace.each do |factory_name, trait_names|
    traits = trait_names.map { |trait_name| FactoryTrace::Structures::Trait.new(trait_name) }
    factory = FactoryTrace::Structures::Factory.new([factory_name], traits)

    collection.add(factory)
  end

  collection
end