Module: Cardiac::ResourceCache::ClassMethods
- Included in:
- Model::Base
- Defined in:
- lib/cardiac/resource/cache.rb
Overview
This extension allows models to opt-in/opt-out of resource caching for the duration of a block, without regard for whether or not the cache has been configured.
This has been “borrowed” from ActiveRecord.
Instance Method Summary collapse
-
#cache(&block) ⇒ Object
Enable the resource cache within the block if Cardiac is configured.
-
#uncached(&block) ⇒ Object
Disable the resource cache within the block if Cardiac is configured.
Instance Method Details
#cache(&block) ⇒ Object
Enable the resource cache within the block if Cardiac is configured. If it’s not, it will execute the given block.
69 70 71 72 73 74 75 |
# File 'lib/cardiac/resource/cache.rb', line 69 def cache(&block) if ::Cardiac::ResourceCache.configured? ::Cardiac::ResourceCache.cache(&block) else yield end end |
#uncached(&block) ⇒ Object
Disable the resource cache within the block if Cardiac is configured. If it’s not, it will execute the given block.
79 80 81 82 83 84 85 |
# File 'lib/cardiac/resource/cache.rb', line 79 def uncached(&block) if ::Cardiac::ResourceCache.configured? ::Cardiac::ResourceCache.uncached(&block) else yield end end |