Method: Workspace#update_entry

Defined in:
lib/notes_cli/models/workspace.rb

#update_entry(key, value) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/notes_cli/models/workspace.rb', line 28

def update_entry(key, value)
  current_config = config
  current_config ? current_config[key] = value.strip.chomp : current_config = { key => value }
  File.open(NotesCli::CONFIG_PATH, 'w') { |file| file.truncate(0) }
  File.open(NotesCli::CONFIG_PATH, 'r+') do |f|
    YAML.dump(current_config, f)
  end
end