aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/store.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/core/store.rb b/core/store.rb
new file mode 100644
index 0000000..4d5e9a7
--- /dev/null
+++ b/core/store.rb
@@ -0,0 +1,29 @@
+require 'pstore'
+
+module Dinobot
+ module Core
+ class Store
+ attr_accessor :data
+
+ def initialize(file)
+ @store = PStore.new(file, true)
+
+ read
+
+ @data ||= {}
+ 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