Class: Cran::PStoreAdapter
- Inherits:
-
Object
- Object
- Cran::PStoreAdapter
- Includes:
- Adapter
- Defined in:
- lib/cran/p_store.rb
Class Method Summary collapse
- .connection ⇒ Object
- .delete(key) ⇒ Object
- .delete_all ⇒ Object
- .list ⇒ Object
- .pull(key) ⇒ Object
- .push(key, value) ⇒ Object
- .transaction ⇒ Object
Methods included from Adapter
Class Method Details
.connection ⇒ Object
9 10 11 |
# File 'lib/cran/p_store.rb', line 9 def connection @connection ||= PStore.new(Config.get(:db, :filename)) end |
.delete(key) ⇒ Object
31 32 33 |
# File 'lib/cran/p_store.rb', line 31 def delete(key) transaction{connection.delete(key)} end |
.delete_all ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/cran/p_store.rb', line 35 def delete_all transaction do connection.roots.each do |key| connection.delete(key) end end end |
.list ⇒ Object
21 22 23 |
# File 'lib/cran/p_store.rb', line 21 def list transaction{connection.roots} end |
.pull(key) ⇒ Object
13 14 15 |
# File 'lib/cran/p_store.rb', line 13 def pull(key) transaction{super} end |
.push(key, value) ⇒ Object
17 18 19 |
# File 'lib/cran/p_store.rb', line 17 def push(key, value) transaction{super} end |
.transaction ⇒ Object
25 26 27 28 29 |
# File 'lib/cran/p_store.rb', line 25 def transaction connection.transaction do yield end end |