Class: Persistent::Store
- Inherits:
-
Object
- Object
- Persistent::Store
- Includes:
- Enumerable
- Defined in:
- lib/persistent/store.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
- #each(&block) ⇒ Object
- #fetch(key, default) ⇒ Object
-
#initialize(key) ⇒ Store
constructor
A new instance of Store.
Constructor Details
#initialize(key) ⇒ Store
Returns a new instance of Store.
6 7 8 |
# File 'lib/persistent/store.rb', line 6 def initialize(key) @store = PStore.new(key) end |
Instance Method Details
#[](key) ⇒ Object
10 11 12 |
# File 'lib/persistent/store.rb', line 10 def [](key) @store.transaction{@store[key]} end |
#[]=(key, value) ⇒ Object
14 15 16 |
# File 'lib/persistent/store.rb', line 14 def []=(key, value) @store.transaction{@store[key] = value} end |
#delete(key) ⇒ Object
22 23 24 |
# File 'lib/persistent/store.rb', line 22 def delete(key) @store.transaction{@store.delete(key)} end |
#each(&block) ⇒ Object
26 27 28 29 |
# File 'lib/persistent/store.rb', line 26 def each(&block) roots = @store.transaction{@store.roots} roots.each(&block) end |
#fetch(key, default) ⇒ Object
18 19 20 |
# File 'lib/persistent/store.rb', line 18 def fetch(key, default) @store.transaction{@store.fetch(key, default)} end |