Class: ActionPolicy::LookupChain::NamespaceCache
- Inherits:
-
Object
- Object
- ActionPolicy::LookupChain::NamespaceCache
- Defined in:
- lib/action_policy/lookup_chain.rb
Overview
Cache namespace resolving result for policies.
Class Attribute Summary collapse
-
.store ⇒ Object
readonly
Returns the value of attribute store.
Class Method Summary collapse
Class Attribute Details
.store ⇒ Object (readonly)
Returns the value of attribute store.
22 23 24 |
# File 'lib/action_policy/lookup_chain.rb', line 22 def store @store end |
Class Method Details
.clear ⇒ Object
30 31 32 |
# File 'lib/action_policy/lookup_chain.rb', line 30 def clear @store = Hash.new { |h, k| h[k] = {} } end |
.fetch(namespace, policy) ⇒ Object
24 25 26 27 28 |
# File 'lib/action_policy/lookup_chain.rb', line 24 def fetch(namespace, policy) return yield unless LookupChain.namespace_cache_enabled? return store[namespace][policy] if store[namespace].key?(policy) store[namespace][policy] ||= yield end |