Module: FactoryTrace::Helpers::Converter
- Defined in:
- lib/factory_trace/helpers/converter.rb
Class Method Summary collapse
- .extract_declarations(structure) ⇒ Array<String>
- .factory(factory) ⇒ FactoryTrace::Structures::Factory
- .trait(trait) ⇒ FactoryTrace::Structures::Trait
Class Method Details
.extract_declarations(structure) ⇒ Array<String>
35 36 37 38 |
# File 'lib/factory_trace/helpers/converter.rb', line 35 def extract_declarations(structure) (structure.definition.declarations.grep(FactoryBot::Declaration::Implicit).map(&:name).map(&:to_s) + structure.definition.instance_variable_get(:@base_traits).map(&:to_s)).uniq end |
.factory(factory) ⇒ FactoryTrace::Structures::Factory
22 23 24 25 26 27 28 29 30 |
# File 'lib/factory_trace/helpers/converter.rb', line 22 def factory(factory) FactoryTrace::Structures::Factory.new( factory.names.map(&:to_s), factory.defined_traits.map(&method(:trait)), parent_name: factory.send(:parent).respond_to?(:name) ? factory.send(:parent).name.to_s : nil, declaration_names: extract_declarations(factory), definition_path: (factory.definition_path if factory.respond_to?(:definition_path)) ) end |
.trait(trait) ⇒ FactoryTrace::Structures::Trait
11 12 13 14 15 16 17 |
# File 'lib/factory_trace/helpers/converter.rb', line 11 def trait(trait) FactoryTrace::Structures::Trait.new( trait.name.to_s, declaration_names: extract_declarations(trait), definition_path: (trait.definition_path if trait.respond_to?(:definition_path)) ) end |