Class: AppCfg::YamlSource
- Defined in:
- lib/appcfg/sources/yaml_source.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ YamlSource
constructor
A new instance of YamlSource.
- #reload_data! ⇒ Object
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( = {}) @filename = [:file] @namespace = [: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 |