Module: Dronejob::Modules::AttrStore
- Extended by:
- ActiveSupport::Concern
- Included in:
- Base
- Defined in:
- lib/dronejob/modules/attr_store.rb
Instance Method Summary collapse
Instance Method Details
#load_variables ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/dronejob/modules/attr_store.rb', line 30 def load_variables yaml_file = working_dir.file("dronejob.yml") variables = yaml_file.exists? ? yaml_file.read_yaml : {} variables.each do |key, value| instance_variable_set("@#{key}", value) end end |
#save_variables ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/dronejob/modules/attr_store.rb', line 21 def save_variables variables = {} self.class.attr_stores.each do |key| variables[key] = instance_variable_get("@#{key}") end yaml_file = working_dir.file("dronejob.yml") yaml_file.write(Psych.dump(variables)) end |