class FactoryBotCaching::CustomizedCache
Attributes
cache[R]
cache_key_generator[R]
Public Class Methods
new(build_class:, cache_key_generator:)
click to toggle source
# 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
Public Instance Methods
fetch(overrides:, traits:, &block)
click to toggle source
# 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()
click to toggle source
# File lib/factory_bot_caching/customized_cache.rb, line 41 def reset_counters cache.each_value(&:reset_counters) end
Private Instance Methods
customized_cache()
click to toggle source
# File lib/factory_bot_caching/customized_cache.rb, line 49 def customized_cache key = cache_key_generator.call cache[key] end