Method: ActionPolicy::PerThreadCache.fetch
- Defined in:
- lib/action_policy/behaviours/thread_memoized.rb
.fetch(key) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/action_policy/behaviours/thread_memoized.rb', line 12 def fetch(key) return yield unless enabled? store = (Thread.current[CACHE_KEY] ||= {}) return store[key] if store.key?(key) store[key] = yield end |