Class: ChefStash::Rash
- Inherits:
-
Object
- Object
- ChefStash::Rash
- Includes:
- Memoizable
- Defined in:
- lib/chef_stash/rash.rb
Instance Method Summary collapse
-
#[](key) ⇒ Object?
(also: #get)
Retrieves a value from the cache.
-
#[]=(key, value) ⇒ Object?
(also: #set)
Stores a value in the cache, either an an argument or block.
-
#delete(key) ⇒ Object?
Removes a value from the cache.
-
#initialize(url, path) ⇒ ChefStash
constructor
Initializes a new store object.
-
#keys ⇒ Array<String, Symbol>
return all keys in the store as an array.
-
#size ⇒ Fixnum
return the size of the store as an integer.
Methods included from Memoizable
Constructor Details
#initialize(url, path) ⇒ ChefStash
Initializes a new store object.
36 37 38 39 |
# File 'lib/chef_stash/rash.rb', line 36 def initialize(url, path) memoize [:fetch] @store ||= fetch(url, path) end |
Instance Method Details
#[](key) ⇒ Object? Also known as: get
Retrieves a value from the cache.
49 50 51 |
# File 'lib/chef_stash/rash.rb', line 49 def [](key) @store[key] end |
#[]=(key, value) ⇒ Object? Also known as: set
Stores a value in the cache, either an an argument or block. If a previous value was set it will be overwritten with the new value.
66 67 68 |
# File 'lib/chef_stash/rash.rb', line 66 def []=(key, value) @store[key] = value end |
#delete(key) ⇒ Object?
Removes a value from the cache.
79 80 81 |
# File 'lib/chef_stash/rash.rb', line 79 def delete(key) @store.delete(key) end |
#keys ⇒ Array<String, Symbol>
return all keys in the store as an array
95 96 97 |
# File 'lib/chef_stash/rash.rb', line 95 def keys @store.keys end |
#size ⇒ Fixnum
return the size of the store as an integer
87 88 89 |
# File 'lib/chef_stash/rash.rb', line 87 def size @store.size end |