Class: Yoda::Store::Registry::Cache::RegistryWrapper
- Inherits:
-
Object
- Object
- Yoda::Store::Registry::Cache::RegistryWrapper
- Extended by:
- Forwardable
- Includes:
- MissingDelegatable
- Defined in:
- lib/yoda/store/registry/cache.rb
Instance Attribute Summary collapse
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #clear_cache ⇒ Object
- #get(key) ⇒ Object
-
#initialize(registry, cache = Registry::Cache.new) ⇒ RegistryWrapper
constructor
A new instance of RegistryWrapper.
Methods included from MissingDelegatable
#delegate_missing_target, included, #method_missing, #respond_to_missing?
Constructor Details
#initialize(registry, cache = Registry::Cache.new) ⇒ RegistryWrapper
Returns a new instance of RegistryWrapper.
17 18 19 20 |
# File 'lib/yoda/store/registry/cache.rb', line 17 def initialize(registry, cache = Registry::Cache.new) @registry = registry @cache = cache end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Yoda::MissingDelegatable
Instance Attribute Details
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
15 16 17 |
# File 'lib/yoda/store/registry/cache.rb', line 15 def registry @registry end |
Instance Method Details
#clear_cache ⇒ Object
28 29 30 |
# File 'lib/yoda/store/registry/cache.rb', line 28 def clear_cache @cache.delete_all end |
#get(key) ⇒ Object
22 23 24 25 26 |
# File 'lib/yoda/store/registry/cache.rb', line 22 def get(key) @cache.fetch_or_calc(key) do @registry.get(key) end end |