Class: Snooby::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/snoobyplus.rb

Overview

Changes to configuration should persist across multiple uses. This class is a simple modification to the standard hash’s setter that updates the config file whenever a value changes.

Instance Method Summary collapse

Instance Method Details

#[]=(key, value) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/snoobyplus.rb', line 33

def []=(key, value)
  super
  return unless Snooby.config # nil during initialization inside JSON#parse
  File.open(CONFIG_FILE, 'w') do |file|
    file << JSON.pretty_generate(Snooby.config)
  end
end