class Flow::Cli::Utils::DbManager

Constants

FLOW_CLI_CONFIG

Public Class Methods

overide_save(hash) click to toggle source
# File lib/flow/cli/utils/db_manager.rb, line 9
def overide_save(hash)
  File.open(FLOW_CLI_CONFIG, "w") do |file|
    file << hash.to_yaml
  end
  hash
end
read() click to toggle source
# File lib/flow/cli/utils/db_manager.rb, line 36
def read
  return {} unless File.file?(FLOW_CLI_CONFIG)
  config = YAML.safe_load(File.read(FLOW_CLI_CONFIG))
  raise "yaml load is not a hash #{config.class}" unless config.is_a? Hash
  config
end
read_attribute(key) click to toggle source
# File lib/flow/cli/utils/db_manager.rb, line 43
def read_attribute(key)
  read[key.to_s]
end
reset() click to toggle source
# File lib/flow/cli/utils/db_manager.rb, line 16
def reset
  overide_save({})
end
save(settings) click to toggle source
# File lib/flow/cli/utils/db_manager.rb, line 20
def save(settings)
  old = read
  settings = old.merge(settings).compact.stringify_keys
  yaml = settings.to_yaml
  File.open(FLOW_CLI_CONFIG, "w") do |file|
    file << yaml
  end
  settings
end
save_attribute(key, val) click to toggle source
# File lib/flow/cli/utils/db_manager.rb, line 30
def save_attribute(key, val)
  dict = read
  dict[key.to_s] = val
  save(dict)
end