Class: CoverRage::Stores::Pstore
- Inherits:
-
Object
- Object
- CoverRage::Stores::Pstore
- Defined in:
- lib/cover_rage/stores/pstore.rb
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize(path) ⇒ Pstore
constructor
A new instance of Pstore.
- #list ⇒ Object
- #transaction ⇒ Object
- #update(records) ⇒ Object
Constructor Details
#initialize(path) ⇒ Pstore
Returns a new instance of Pstore.
9 10 11 |
# File 'lib/cover_rage/stores/pstore.rb', line 9 def initialize(path) @store = PStore.new(path, true) end |
Instance Method Details
#clear ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/cover_rage/stores/pstore.rb', line 42 def clear if @transaction @store.keys.each { @store.delete(_1) } else @store.transaction do @store.keys.each { @store.delete(_1) } end end end |
#list ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/cover_rage/stores/pstore.rb', line 32 def list if @transaction @store.keys.map { @store[_1] } else @store.transaction do @store.keys.map { @store[_1] } end end end |
#transaction ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/cover_rage/stores/pstore.rb', line 13 def transaction @store.transaction do @transaction = true yield ensure @transaction = false end end |
#update(records) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/cover_rage/stores/pstore.rb', line 22 def update(records) if @transaction records.each { @store[_1.path] = _1 } else @store.transaction do records.each { @store[_1.path] = _1 } end end end |