2017-10-20 15:20:28 -04:00
|
|
|
module FactoryBot
|
2012-05-12 10:27:47 -04:00
|
|
|
# @api private
|
|
|
|
class Configuration
|
2019-02-13 17:24:28 -05:00
|
|
|
attr_reader(
|
|
|
|
:callback_names,
|
|
|
|
:factories,
|
|
|
|
:inline_sequences,
|
|
|
|
:sequences,
|
|
|
|
:strategies,
|
2020-06-05 15:15:18 -04:00
|
|
|
:traits
|
2019-02-13 17:24:28 -05:00
|
|
|
)
|
2012-05-12 10:27:47 -04:00
|
|
|
|
|
|
|
def initialize
|
2020-06-05 15:15:18 -04:00
|
|
|
@factories = Decorator::DisallowsDuplicatesRegistry.new(Registry.new("Factory"))
|
|
|
|
@sequences = Decorator::DisallowsDuplicatesRegistry.new(Registry.new("Sequence"))
|
|
|
|
@traits = Decorator::DisallowsDuplicatesRegistry.new(Registry.new("Trait"))
|
|
|
|
@strategies = Registry.new("Strategy")
|
2012-05-12 10:27:47 -04:00
|
|
|
@callback_names = Set.new
|
2020-06-05 15:15:18 -04:00
|
|
|
@definition = Definition.new(:configuration)
|
2019-02-13 17:24:28 -05:00
|
|
|
@inline_sequences = []
|
2012-05-12 00:42:44 -04:00
|
|
|
|
2018-10-07 18:02:54 -04:00
|
|
|
to_create(&:save!)
|
2012-05-12 18:53:17 -04:00
|
|
|
initialize_with { new }
|
2012-05-12 10:27:47 -04:00
|
|
|
end
|
2012-05-12 00:42:44 -04:00
|
|
|
|
2013-02-08 11:00:22 -05:00
|
|
|
delegate :to_create, :skip_create, :constructor, :before, :after,
|
2020-06-05 15:15:18 -04:00
|
|
|
:callback, :callbacks, to: :@definition
|
2012-05-12 18:53:17 -04:00
|
|
|
|
|
|
|
def initialize_with(&block)
|
|
|
|
@definition.define_constructor(&block)
|
|
|
|
end
|
2012-05-12 10:27:47 -04:00
|
|
|
end
|
|
|
|
end
|