1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
thoughtbot--factory_bot/lib/factory_bot/configuration.rb

34 lines
908 B
Ruby
Raw Permalink Normal View History

module FactoryBot
2012-05-12 10:27:47 -04:00
# @api private
class Configuration
attr_reader(
:callback_names,
:factories,
:inline_sequences,
:sequences,
:strategies,
:traits
)
2012-05-12 10:27:47 -04:00
def initialize
@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
@definition = Definition.new(:configuration)
@inline_sequences = []
2018-10-07 18:02:54 -04:00
to_create(&:save!)
initialize_with { new }
2012-05-12 10:27:47 -04:00
end
delegate :to_create, :skip_create, :constructor, :before, :after,
:callback, :callbacks, to: :@definition
def initialize_with(&block)
@definition.define_constructor(&block)
end
2012-05-12 10:27:47 -04:00
end
end