class ArisControl::Persistence
Attributes
apps_file_path[R]
Public Class Methods
new(apps_file_path = default_apps_file_path)
click to toggle source
# File lib/aris-control/persistence.rb, line 8 def initialize(apps_file_path = default_apps_file_path) @apps_file_path = Pathname.new(apps_file_path) end
Public Instance Methods
default_apps_file_path()
click to toggle source
# File lib/aris-control/persistence.rb, line 23 def default_apps_file_path '/opt/aris/config/apps.yml' end
load_apps()
click to toggle source
# File lib/aris-control/persistence.rb, line 18 def load_apps store_apps({}) unless apps_file_path.exist? deserialized_apps(IO.binread(apps_file_path)) end
store_apps(apps)
click to toggle source
# File lib/aris-control/persistence.rb, line 12 def store_apps(apps) apps ||= {} IO.binwrite(apps_file_path, serialized_apps(apps)) apps end
Private Instance Methods
deserialized_apps(string)
click to toggle source
# File lib/aris-control/persistence.rb, line 33 def deserialized_apps(string) yaml = YAML.load(string) || {} yaml['aris_apps'] || {} end
serialized_apps(apps)
click to toggle source
# File lib/aris-control/persistence.rb, line 29 def serialized_apps(apps) YAML.dump({ 'aris_apps' => apps }) end