Class: FactoryBotFactory::HashFactory
- Inherits:
-
BaseFactory
- Object
- BaseFactory
- FactoryBotFactory::HashFactory
- Defined in:
- lib/factory_bot_factory/factories/hash_factory.rb
Instance Method Summary collapse
Methods inherited from BaseFactory
Constructor Details
This class inherits a constructor from FactoryBotFactory::BaseFactory
Instance Method Details
#build_factory(name, value, level) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/factory_bot_factory/factories/hash_factory.rb', line 5 def build_factory(name, value, level) output = LineWriter.wrap_factory(name, 'Hash') do inner_output = [] value = value.attributes if value.respond_to?(:attributes) value = value.to_h if value.respond_to?(:to_h) value.each do |key, value| inner_output += build_nested_attribute(name, key, value, 1, level) end inner_output << "initialize_with { attributes }" inner_output end output end |