Class: AppCfg::YamlSource

Inherits:
Source
  • Object
show all
Defined in:
lib/appcfg/sources/yaml_source.rb

Instance Method Summary collapse

Methods inherited from Source

add, clear, list, reload_sources!, #to_hash

Constructor Details

#initialize(options = {}) ⇒ YamlSource

Returns a new instance of YamlSource.



3
4
5
6
# File 'lib/appcfg/sources/yaml_source.rb', line 3

def initialize(options = {})
  @filename  = options[:file]
  @namespace = options[:env]
end

Instance Method Details

#reload_data!Object



8
9
10
11
# File 'lib/appcfg/sources/yaml_source.rb', line 8

def reload_data!
  yaml_structure = YAML.load(File.open @filename) || {} # empty hash instead of false when file is empty
  @hash          = @namespace ? yaml_structure[@namespace]||{} : yaml_structure
end