class SmartProxyDynflowCore::Settings

Constants

DEFAULT_SETTINGS
PLUGIN_SETTINGS
PROXY_SETTINGS

Public Class Methods

instance() click to toggle source
# File lib/smart_proxy_dynflow_core/settings.rb, line 54
def self.instance
  SmartProxyDynflowCore::SETTINGS
end
load_from_proxy(plugin) click to toggle source
# File lib/smart_proxy_dynflow_core/settings.rb, line 72
def self.load_from_proxy(plugin)
  settings = plugin[:class].settings.to_h
  PROXY_SETTINGS.each do |key|
    SETTINGS[key] = Proxy::SETTINGS[key]
  end
  PLUGIN_SETTINGS.each do |key|
    SETTINGS[key] = settings[key] if settings.key?(key)
  end
  SETTINGS.plugins.values.each { |plugin| plugin.load_settings_from_proxy }
  Settings.loaded!
end
load_global_settings(path) click to toggle source
# File lib/smart_proxy_dynflow_core/settings.rb, line 58
def self.load_global_settings(path)
  if File.exists? File.join(path)
    YAML.load_file(path).each do |key, value|
      SETTINGS[key] = value
    end
  end
end
load_plugin_settings(path) click to toggle source
# File lib/smart_proxy_dynflow_core/settings.rb, line 84
def self.load_plugin_settings(path)
  settings = YAML.load_file(path)
  name = File.basename(path).gsub(/\.yml$/, '')
  if SETTINGS.plugins.key? name
    settings = SETTINGS.plugins[name].to_h.merge(settings)
  end
  SETTINGS.plugins[name] = OpenStruct.new settings
end
loaded!() click to toggle source
# File lib/smart_proxy_dynflow_core/settings.rb, line 66
def self.loaded!
  Settings.instance.loaded = true
  Log.instance.info 'Settings loaded, reloading logger'
  Log.reload!
end
new(settings = {}) click to toggle source
Calls superclass method
# File lib/smart_proxy_dynflow_core/settings.rb, line 50
def initialize(settings = {})
  super(DEFAULT_SETTINGS.merge(settings))
end