Class: CrossPost::Config::FileSubConfig

Inherits:
SubConfig
  • Object
show all
Defined in:
lib/cross-post/config.rb

Instance Method Summary collapse

Methods inherited from SubConfig

#[], #[]=, #each, #fetch

Constructor Details

#initialize(file) ⇒ FileSubConfig

Returns a new instance of FileSubConfig.



79
80
81
82
# File 'lib/cross-post/config.rb', line 79

def initialize(file)
	@file = file
	super YAML.load_file @file
end

Instance Method Details

#put(key, value, save: false) ⇒ Object



84
85
86
87
# File 'lib/cross-post/config.rb', line 84

def put(key, value, save: false)
	self[key] = value
	self.save if save
end

#saveObject



89
90
91
92
93
# File 'lib/cross-post/config.rb', line 89

def save
	LOGGER.debug "Saving #{@file}"
	yaml = YAML.dump @config
	File.write @file, yaml
end