Class: FactoryBotFactory::ModelFactory

Inherits:
BaseFactory show all
Defined in:
lib/factory_bot_factory/factories/model_factory.rb

Direct Known Subclasses

ActiveRecordFactory

Instance Method Summary collapse

Methods inherited from BaseFactory

#generate, #initialize

Constructor Details

This class inherits a constructor from FactoryBotFactory::BaseFactory

Instance Method Details

#build_factory(name, value, level, _options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/factory_bot_factory/factories/model_factory.rb', line 3

def build_factory(name, value, level, _options = {})
  output = LineWriter.wrap_factory(name, value.class.name) do
    inner_output = []
    value.attributes.each do |key, value|
      inner_output += build_nested_attribute(value.class.name, key, value, 1, 1)
    end
    inner_output
  end
  output
end