Module: Omnitest::Skeptic::Evidence::Persistable
- Included in:
- Omnitest::Skeptic::Evidence
- Defined in:
- lib/omnitest/skeptic/evidence.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#autosave ⇒ Object
writeonly
Sets the attribute autosave.
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
- #[]=(key, value) ⇒ Object
- #autosave? ⇒ Boolean
- #clear ⇒ Object
- #initialize(file, initial_data = {}) ⇒ Object
- #reload ⇒ Object
- #save ⇒ Object
Instance Attribute Details
#autosave=(value) ⇒ Object (writeonly)
Sets the attribute autosave
8 9 10 |
# File 'lib/omnitest/skeptic/evidence.rb', line 8 def autosave=(value) @autosave = value end |
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/omnitest/skeptic/evidence.rb', line 7 def file @file end |
Class Method Details
.included(base) ⇒ Object
16 17 18 |
# File 'lib/omnitest/skeptic/evidence.rb', line 16 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#[]=(key, value) ⇒ Object
26 27 28 29 |
# File 'lib/omnitest/skeptic/evidence.rb', line 26 def []=(key, value) super save if autosave? end |
#autosave? ⇒ Boolean
31 32 33 |
# File 'lib/omnitest/skeptic/evidence.rb', line 31 def autosave? @autosave == true end |
#clear ⇒ Object
51 52 53 54 |
# File 'lib/omnitest/skeptic/evidence.rb', line 51 def clear @store = nil file.delete end |
#initialize(file, initial_data = {}) ⇒ Object
20 21 22 23 24 |
# File 'lib/omnitest/skeptic/evidence.rb', line 20 def initialize(file, initial_data = {}) @file = Pathname(file) FileUtils.mkdir_p(@file.dirname) super initial_data end |
#reload ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/omnitest/skeptic/evidence.rb', line 35 def reload store.transaction do store.roots.each do | key | self[key] = store[key] end end end |
#save ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/omnitest/skeptic/evidence.rb', line 43 def save store.transaction do keys.each do | key | store[key] = self[key] end end end |