Module: ActionPolicy::PerThreadCache
- Defined in:
- lib/action_policy/behaviours/thread_memoized.rb
Overview
:nodoc:
Constant Summary collapse
- CACHE_KEY =
"action_policy.per_thread_cache"
Class Method Summary collapse
Class Method Details
.clear_all ⇒ Object
16 17 18 |
# File 'lib/action_policy/behaviours/thread_memoized.rb', line 16 def clear_all Thread.current[CACHE_KEY] = {} end |
.fetch(key) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/action_policy/behaviours/thread_memoized.rb', line 8 def fetch(key) store = (Thread.current[CACHE_KEY] ||= {}) return store[key] if store.key?(key) store[key] = yield end |