blob: ba49733f18b0fdc0dd8cd4a5a204c6cb49acc665 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
require 'pstore'
module Dinobot
module Core
class Store
attr_accessor :data
def initialize(file)
Dir.mkdir(File.dirname(file)) unless Dir.exist?(File.dirname(file))
@store = PStore.new(file, true)
read
@data ||= Hash.new
end
def read
@store.transaction(true) do
@data = @store[:data]
end
end
def save
@store.transaction do
@store[:data] = @data
end
end
end
end
end
|