Class: CanTango::Cache::HashCache
- Inherits:
-
Object
- Object
- CanTango::Cache::HashCache
- Includes:
- Singleton
- Defined in:
- lib/cantango/cache/hash_cache.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #cache ⇒ Object
- #configure_with(options = {}) ⇒ Object
- #delete(key) ⇒ Object
- #load!(key) ⇒ Object
- #save!(key, rules) ⇒ Object
- #type ⇒ Object
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/cantango/cache/hash_cache.rb', line 6 def @options end |
Instance Method Details
#cache ⇒ Object
27 28 29 |
# File 'lib/cantango/cache/hash_cache.rb', line 27 def cache @cache ||= {} end |
#configure_with(options = {}) ⇒ Object
8 9 10 |
# File 'lib/cantango/cache/hash_cache.rb', line 8 def configure_with = {} @options ||= end |
#delete(key) ⇒ Object
22 23 24 25 |
# File 'lib/cantango/cache/hash_cache.rb', line 22 def delete key raise "no key" if key.nil? cache[key].delete if cache[key] end |
#load!(key) ⇒ Object
12 13 14 15 |
# File 'lib/cantango/cache/hash_cache.rb', line 12 def load! key raise "no key" if key.nil? cache[key] end |
#save!(key, rules) ⇒ Object
17 18 19 20 |
# File 'lib/cantango/cache/hash_cache.rb', line 17 def save! key, rules raise "no key" if key.nil? cache[key] = rules end |
#type ⇒ Object
31 32 33 |
# File 'lib/cantango/cache/hash_cache.rb', line 31 def type :memory end |