aboutsummaryrefslogtreecommitdiff
path: root/core/config.rb
diff options
context:
space:
mode:
Diffstat (limited to 'core/config.rb')
-rw-r--r--core/config.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/core/config.rb b/core/config.rb
new file mode 100644
index 0000000..fec2e18
--- /dev/null
+++ b/core/config.rb
@@ -0,0 +1,43 @@
+require_relative 'store'
+
+module Dinobot
+ module Core
+ class Config
+ attr_accessor :data
+
+ @@instance = nil
+ @@mutex = Mutex.new
+
+ def initialize
+ @store = Dinobot::Core::Store.new('config')
+ @data = @store.data[:data]
+
+ if @data.nil?
+ @data = Hash.new
+
+ @data[:trigger] = Hash.new
+ @data[:trigger][:global] = '!'
+
+ save
+ end
+ end
+
+ def save
+ @store.data[:data] = @data
+ @store.save
+ end
+
+ class << self
+ def instance
+ return @@instance if @@instance
+
+ @@mutex.synchronize do
+ @@instance ||= new
+ end
+ end
+ end
+
+ private_class_method :allocate, :new
+ end
+ end
+end