Class: FactoryBotCaching::CacheManager
- Inherits:
-
Object
- Object
- FactoryBotCaching::CacheManager
- Defined in:
- lib/factory_bot_caching/cache_manager.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fetch(name:, overrides:, traits:, &block) ⇒ Object
-
#initialize ⇒ CacheManager
constructor
A new instance of CacheManager.
- #reset_cache ⇒ Object
- #reset_cache_counter ⇒ Object
Constructor Details
#initialize ⇒ CacheManager
33 34 35 36 37 |
# File 'lib/factory_bot_caching/cache_manager.rb', line 33 def initialize @factory_cache = Hash.new do |hash, key| hash[key] = FactoryCache.new(factory_name: key) end end |
Class Method Details
.instance ⇒ Object
29 30 31 |
# File 'lib/factory_bot_caching/cache_manager.rb', line 29 def self.instance @instance ||= self.new end |
Instance Method Details
#fetch(name:, overrides:, traits:, &block) ⇒ Object
47 48 49 |
# File 'lib/factory_bot_caching/cache_manager.rb', line 47 def fetch(name:, overrides:, traits:, &block) factory_cache[name].fetch(overrides: overrides, traits: traits, &block) end |
#reset_cache ⇒ Object
39 40 41 |
# File 'lib/factory_bot_caching/cache_manager.rb', line 39 def reset_cache factory_cache.each_value(&:reset) end |
#reset_cache_counter ⇒ Object
43 44 45 |
# File 'lib/factory_bot_caching/cache_manager.rb', line 43 def reset_cache_counter factory_cache.each_value(&:reset_counter) end |