Class: Rotten::Cache
- Inherits:
-
Object
- Object
- Rotten::Cache
- Defined in:
- lib/rotten/cache.rb
Instance Attribute Summary collapse
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Cache
constructor
A new instance of Cache.
- #method_missing(sym, *args, &block) ⇒ Object
- #read(key) ⇒ Object (also: #get)
- #write(key, value) ⇒ Object (also: #set)
Constructor Details
#initialize(options = {}) ⇒ Cache
Returns a new instance of Cache.
10 11 12 |
# File 'lib/rotten/cache.rb', line 10 def initialize ={} @store = .delete(:store) || SimpleCache.new() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
24 25 26 |
# File 'lib/rotten/cache.rb', line 24 def method_missing sym, *args, &block @store.send sym, *args, &block end |
Instance Attribute Details
#store ⇒ Object (readonly)
Returns the value of attribute store.
9 10 11 |
# File 'lib/rotten/cache.rb', line 9 def store @store end |
Instance Method Details
#read(key) ⇒ Object Also known as: get
14 15 16 |
# File 'lib/rotten/cache.rb', line 14 def read key @store.read key end |
#write(key, value) ⇒ Object Also known as: set
19 20 21 |
# File 'lib/rotten/cache.rb', line 19 def write key, value @store.write key, value end |