Class: Satisfactory::Loader Private
- Inherits:
-
Object
- Object
- Satisfactory::Loader
- Defined in:
- lib/satisfactory/loader.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Loads factory configurations from FactoryBot.
Class Method Summary collapse
-
.factory_configurations ⇒ {Symbol => Hash}
private
Skips factories that don’t have a model that inherits from ApplicationRecord.
Class Method Details
.factory_configurations ⇒ {Symbol => Hash}
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Skips factories that don’t have a model that inherits from ApplicationRecord.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/satisfactory/loader.rb', line 12 def factory_configurations # rubocop:disable Metrics/AbcSize FactoryBot.factories.each.with_object({}) do |(factory, model), configurations| next unless (model = factory.build_class) next unless model < ApplicationRecord associations = associations_for(model) parent_factory = factory.send(:parent) configurations[factory.name] = { associations: associations.transform_values { |a| a.map(&:name) }, model:, name: factory.name, parent: (parent_factory.name unless parent_factory.is_a?(FactoryBot::NullFactory)), traits: factory.defined_traits.map(&:name), } end end |