Class: AssetsInclude::Cache
- Inherits:
-
Object
- Object
- AssetsInclude::Cache
- Defined in:
- lib/assets_include/cache.rb
Instance Method Summary collapse
- #add(key, &block) ⇒ Object
- #empty ⇒ Object
- #get(key) ⇒ Object
-
#initialize ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize ⇒ Cache
Returns a new instance of Cache.
3 4 5 |
# File 'lib/assets_include/cache.rb', line 3 def initialize @store = {} end |
Instance Method Details
#add(key, &block) ⇒ Object
7 8 9 |
# File 'lib/assets_include/cache.rb', line 7 def add(key, &block) store[key] ||= yield end |
#empty ⇒ Object
15 16 17 |
# File 'lib/assets_include/cache.rb', line 15 def empty store.clear end |
#get(key) ⇒ Object
11 12 13 |
# File 'lib/assets_include/cache.rb', line 11 def get(key) store[key] end |