class Flipflop::FeatureCache
Public Class Methods
current()
click to toggle source
# File lib/flipflop/feature_cache.rb, line 24 def current Thread.current.thread_variable_get(:flipflop_cache) or Thread.current.thread_variable_set(:flipflop_cache, new) end
new()
click to toggle source
# File lib/flipflop/feature_cache.rb, line 32 def initialize @enabled = false @cache = {} end
Public Instance Methods
clear!()
click to toggle source
# File lib/flipflop/feature_cache.rb, line 41 def clear! @cache.clear end
disable!()
click to toggle source
# File lib/flipflop/feature_cache.rb, line 49 def disable! @enabled = false @cache.clear end
enable!()
click to toggle source
# File lib/flipflop/feature_cache.rb, line 45 def enable! @enabled = true end
enabled?()
click to toggle source
# File lib/flipflop/feature_cache.rb, line 37 def enabled? @enabled end
fetch(key) { || ... }
click to toggle source
# File lib/flipflop/feature_cache.rb, line 54 def fetch(key) if @enabled @cache.fetch(key) do @cache[key] = yield end else yield end end