Class: KAG::Config

Inherits:
SymbolTable
  • Object
show all
Includes:
Singleton
Defined in:
lib/kag/config.rb

Constant Summary collapse

@@data =
KAG::Data.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



11
12
13
14
# File 'lib/kag/config.rb', line 11

def initialize
  super
  self.merge!(self._get_config)
end

Class Method Details

.dataObject



29
30
31
# File 'lib/kag/config.rb', line 29

def self.data
  @@data
end

Instance Method Details

#_get_configObject



16
17
18
19
20
21
22
# File 'lib/kag/config.rb', line 16

def _get_config
  if File.exists?("config/config.json")
    SymbolTable.new(JSON.parse(::IO.read("config/config.json")))
  else
    raise 'Error loading config file from config/config.json'
  end
end

#reloadObject



24
25
26
27
# File 'lib/kag/config.rb', line 24

def reload
  puts "Reloading configuration file..."
  self.merge!(self._get_config)
end