Class: Cloudscale::Preops::PluginSettingsDb
- Inherits:
-
Object
- Object
- Cloudscale::Preops::PluginSettingsDb
- Includes:
- Singleton
- Defined in:
- lib/cloudscale/monitor/plugin/settings_db.rb
Instance Attribute Summary collapse
-
#log ⇒ Object
Returns the value of attribute log.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #clear_options ⇒ Object
- #get_option(key) ⇒ Object
- #get_option_value(key) ⇒ Object
- #init_options ⇒ Object
-
#initialize ⇒ PluginSettingsDb
constructor
A new instance of PluginSettingsDb.
- #save_options ⇒ Object
- #set_option_value(key, val) ⇒ Object
Constructor Details
#initialize ⇒ PluginSettingsDb
Returns a new instance of PluginSettingsDb.
15 16 17 18 19 20 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 15 def initialize @log = Logger.new(STDOUT) = Hash.new @plugin_settings_db = FSDB::Database.new("#{File.dirname(__FILE__)}/../../../store/plugin/") () end |
Instance Attribute Details
#log ⇒ Object
Returns the value of attribute log.
13 14 15 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 13 def log @log end |
#options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 13 def end |
Instance Method Details
#clear_options ⇒ Object
52 53 54 55 56 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 52 def @plugin_settings_db.fetch.each do | element | @plugin_settings_db.delete(element) end end |
#get_option(key) ⇒ Object
26 27 28 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 26 def get_option(key) [key.to_sym] end |
#get_option_value(key) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 30 def get_option_value(key) if ([key.to_sym] != nil) [key.to_sym][:value] #|| @plugin_settings_db[key.to_s] else nil end end |
#init_options ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 38 def @plugin_settings_db.fetch.each do | key | if ([key.to_sym]) [key.to_sym][:value] = @plugin_settings_db[key] end end end |
#save_options ⇒ Object
46 47 48 49 50 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 46 def .each do | key, value | @plugin_settings_db[key.to_s] = value[:value].to_s end end |
#set_option_value(key, val) ⇒ Object
22 23 24 |
# File 'lib/cloudscale/monitor/plugin/settings_db.rb', line 22 def set_option_value(key, val) [key.to_sym][:value] = val end |