Class: EacRailsGemSupport::FactoryBot::InstanceRegistry
- Inherits:
-
Object
- Object
- EacRailsGemSupport::FactoryBot::InstanceRegistry
- Defined in:
- lib/eac_rails_gem_support/factory_bot/instance_registry.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.default ⇒ Object
7 8 9 |
# File 'lib/eac_rails_gem_support/factory_bot/instance_registry.rb', line 7 def default @default ||= ::EacRailsGemSupport::FactoryBot::InstanceRegistry.new end |
.sanitize_key(key) ⇒ Object
13 14 15 |
# File 'lib/eac_rails_gem_support/factory_bot/instance_registry.rb', line 13 def sanitize_key(key) key.to_sym end |
Instance Method Details
#fetch(key) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/eac_rails_gem_support/factory_bot/instance_registry.rb', line 18 def fetch(key) key = self.class.sanitize_key(key) if fetched.key?(key) fetched.fetch(key) else fetched[key] = ::FactoryBot.create(key) end end |
#reset ⇒ Object
27 28 29 |
# File 'lib/eac_rails_gem_support/factory_bot/instance_registry.rb', line 27 def reset @fetched = nil end |