class Madhouse::DataFile

Constants

DATA_ROOT
DEFAULT_FILENAME

Public Class Methods

new(namespace) click to toggle source
# File lib/madhouse.rb, line 30
def initialize(namespace)
  @namespace = namespace
end

Public Instance Methods

content() click to toggle source
# File lib/madhouse.rb, line 38
def content
  return unless exist?
  store.transaction(true) do
    store[DATA_ROOT]
  end
end
exist?() click to toggle source
# File lib/madhouse.rb, line 51
def exist?
  File.exist?(location)
end
location() click to toggle source
# File lib/madhouse.rb, line 34
def location
  File.expand_path(File.join('~', ".#{@namespace}", DEFAULT_FILENAME))
end
update(data) click to toggle source
# File lib/madhouse.rb, line 45
def update(data)
  store.transaction do
    store[DATA_ROOT] = data
  end
end

Private Instance Methods

store() click to toggle source
# File lib/madhouse.rb, line 57
def store
  @_store ||= PStore.new(location)
end