Class: Flydata::Helper::Action::UpdateHelperConfig

Inherits:
BaseAction
  • Object
show all
Defined in:
lib/flydata/helper/action/update_helper_config.rb

Instance Attribute Summary

Attributes inherited from BaseAction

#config

Instance Method Summary collapse

Methods inherited from BaseAction

#config_hash, #initialize

Constructor Details

This class inherits a constructor from Flydata::Helper::BaseAction

Instance Method Details

#execute(opts = {}) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flydata/helper/action/update_helper_config.rb', line 7

def execute(opts = {})
  conf_path = config[:config_path] || FLYDATA_HELPER_CONF
  helper_conf = opts[:config]
  helper_conf = "#{helper_conf}\n" if helper_conf && helper_conf.size > 0 && !helper_conf.end_with?("\n")
  if helper_conf
    log_info("updating Helper config:#{conf_path}")
    File.open(conf_path, "w") {|f| f.write helper_conf }
  else
    log_info("removing Helper config:#{conf_path}")
    File.unlink(conf_path) if File.exists?(conf_path)
  end
  # reload conf
  Process.kill("USR2", Process.ppid)
end