Disappointing …
Not “user friendly”. Who will the user blame when a glitch causes the settings not to be stored ?
@medeek You might think about writing to and reading from, your own json file.
require 'json'
# Where @options is a local Hash or OpenStruct instance object.
def save_options(filepath)
json_str = JSON.generate(@options)
File.open(filepath,"w:UTF-8:#{__ENCODING__}") {|io| io.write(json_str) }
rescue => e
# Notify user there was an error saving options.
end
def retrieve_options(filepath)
if File::exist?(filepath)
json_str = File.read(filepath,"r:UTF-8:#{__ENCODING__}")
@options = JSON.parse(json_str)
else
save_options(filepath)
end
rescue => e
# Notify user there was an error retrieving options.
end
Or, yaml or whatever works.
The Ruby standard library also has a PStore lib which is very similar to json.