Class: Juno::Adapters::PStore
- Inherits:
-
Base
- Object
- Base
- Juno::Adapters::PStore
show all
- Defined in:
- lib/juno/adapters/pstore.rb
Overview
Direct Known Subclasses
YAML
Instance Method Summary
collapse
Methods inherited from Base
#[], #[]=, #close, #fetch
Constructor Details
#initialize(options = {}) ⇒ PStore
14
15
16
17
18
|
# File 'lib/juno/adapters/pstore.rb', line 14
def initialize(options = {})
raise ArgumentError, 'Option :file is required' unless options[:file]
FileUtils.mkpath(::File.dirname(options[:file]))
@pstore = new_store(options)
end
|
Instance Method Details
#clear(options = {}) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/juno/adapters/pstore.rb', line 36
def clear(options = {})
@pstore.transaction do
@pstore.roots.each do |key|
@pstore.delete(key)
end
end
self
end
|
#delete(key, options = {}) ⇒ Object
28
29
30
|
# File 'lib/juno/adapters/pstore.rb', line 28
def delete(key, options = {})
@pstore.transaction { @pstore.delete(key) }
end
|
#key?(key, options = {}) ⇒ Boolean
20
21
22
|
# File 'lib/juno/adapters/pstore.rb', line 20
def key?(key, options = {})
@pstore.transaction(true) { @pstore.root?(key) }
end
|
#load(key, options = {}) ⇒ Object
24
25
26
|
# File 'lib/juno/adapters/pstore.rb', line 24
def load(key, options = {})
@pstore.transaction(true) { @pstore[key] }
end
|
#store(key, value, options = {}) ⇒ Object
32
33
34
|
# File 'lib/juno/adapters/pstore.rb', line 32
def store(key, value, options = {})
@pstore.transaction { @pstore[key] = value }
end
|