2017-10-20 15:20:28 -04:00
|
|
|
module FactoryBot
|
2012-05-12 10:27:47 -04:00
|
|
|
# @api private
|
|
|
|
class Configuration
|
|
|
|
attr_reader :factories, :sequences, :traits, :strategies, :callback_names
|
|
|
|
|
2016-12-16 05:28:09 -05:00
|
|
|
attr_accessor :allow_class_lookup, :use_parent_strategy
|
2016-02-29 16:35:34 -05:00
|
|
|
|
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)
|
2012-05-12 00:42:44 -04:00
|
|
|
|
2016-02-29 16:35:34 -05:00
|
|
|
@allow_class_lookup = true
|
|
|
|
|
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,
|
|
|
|
: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
|