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,
|
|
|
|
:traits,
|
|
|
|
)
|
2012-05-12 10:27:47 -04:00
|
|
|
|
|
|
|
def initialize
|
2018-10-07 21:45:51 -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
|
2018-08-04 10:06:57 -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,
|
2019-05-12 22:39:55 -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
|