Class: FactoryBotCaching::CustomizedCache
- Inherits:
-
Object
- Object
- FactoryBotCaching::CustomizedCache
- Defined in:
- lib/factory_bot_caching/customized_cache.rb
Instance Method Summary collapse
- #fetch(overrides:, traits:, &block) ⇒ Object
-
#initialize(build_class:, cache_key_generator:) ⇒ CustomizedCache
constructor
A new instance of CustomizedCache.
- #reset_counters ⇒ Object
Constructor Details
#initialize(build_class:, cache_key_generator:) ⇒ CustomizedCache
30 31 32 33 34 35 |
# File 'lib/factory_bot_caching/customized_cache.rb', line 30 def initialize(build_class:, cache_key_generator:) @cache_key_generator = cache_key_generator @cache = Hash.new do |hash, key| hash[key] = FactoryRecordCache.new(build_class: build_class) end end |
Instance Method Details
#fetch(overrides:, traits:, &block) ⇒ Object
37 38 39 |
# File 'lib/factory_bot_caching/customized_cache.rb', line 37 def fetch(overrides:, traits:, &block) customized_cache.fetch(overrides: overrides, traits: traits, &block) end |
#reset_counters ⇒ Object
41 42 43 |
# File 'lib/factory_bot_caching/customized_cache.rb', line 41 def reset_counters cache.each_value(&:reset_counters) end |