Class: Madhouse::DataFile
- Inherits:
-
Object
- Object
- Madhouse::DataFile
- Defined in:
- lib/madhouse.rb
Constant Summary collapse
- DEFAULT_FILENAME =
'data.pstore'- DATA_ROOT =
'root'
Instance Method Summary collapse
- #content ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(namespace) ⇒ DataFile
constructor
A new instance of DataFile.
- #location ⇒ Object
- #update(data) ⇒ Object
Constructor Details
#initialize(namespace) ⇒ DataFile
Returns a new instance of DataFile.
30 31 32 |
# File 'lib/madhouse.rb', line 30 def initialize(namespace) @namespace = namespace end |
Instance Method Details
#content ⇒ Object
38 39 40 41 42 43 |
# File 'lib/madhouse.rb', line 38 def content return unless exist? store.transaction(true) do store[DATA_ROOT] end end |
#exist? ⇒ Boolean
51 52 53 |
# File 'lib/madhouse.rb', line 51 def exist? File.exist?(location) end |
#location ⇒ Object
34 35 36 |
# File 'lib/madhouse.rb', line 34 def location File.(File.join('~', ".#{@namespace}", DEFAULT_FILENAME)) end |
#update(data) ⇒ Object
45 46 47 48 49 |
# File 'lib/madhouse.rb', line 45 def update(data) store.transaction do store[DATA_ROOT] = data end end |