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
Daniel Colson 2e0b47639c
Remove deprecated factory lookup by class (#1212)
Closes #1196

We deprecated looking up factories by class in #877. We introduced
`allow_class_lookup` option so that people could disable the behavior
entirely after fixing the deprecation warning.

In preparation for factory_bot 5, I am removing the deprecation warning
and the `allow_class_lookup` option. It is no longer possible to look
up factories by class. This has also made the ClassKeyHash decorator
unnecessary. The behavior is technically a little different now
that we are using HashWithIndifferentAccess
instead of calling to_sym on the key, but it
should behave identically for any standard,
documented factory_bot usage.
2018-10-12 16:59:02 -04:00

27 lines
883 B
Ruby

module FactoryBot
# @api private
class Configuration
attr_reader :factories, :sequences, :traits, :strategies, :callback_names
attr_accessor :use_parent_strategy
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")
@callback_names = Set.new
@definition = Definition.new(:configuration)
to_create(&:save!)
initialize_with { new }
end
delegate :to_create, :skip_create, :constructor, :before, :after,
:callback, :callbacks, to: :@definition
def initialize_with(&block)
@definition.define_constructor(&block)
end
end
end