Class: SettingsReader::Backends::YamlFile

Inherits:
Abstract
  • Object
show all
Defined in:
lib/settings_reader/backends/yaml_file.rb

Overview

Provides access to settings stored as YAML file. File will be read once on init and cached in memory:

When file is missing - no error will be raised
When file is invalid - SettingsReader::Error is raised

Constant Summary

Constants included from Mixins::Values

Mixins::Values::PARSING_CLASSES

Constants included from Mixins::Path

Mixins::Path::PATH_SEPARATOR

Instance Method Summary collapse

Methods included from Mixins::Values

#cast_value_from_string, #get_value_from_hash

Methods included from Mixins::Path

#decompose_path, #generate_path

Constructor Details

#initialize(file_path) ⇒ YamlFile

Returns a new instance of YamlFile.



10
11
12
13
# File 'lib/settings_reader/backends/yaml_file.rb', line 10

def initialize(file_path)
  super()
  @data = read_yml(file_path)
end

Instance Method Details

#get(path) ⇒ Object



15
16
17
18
# File 'lib/settings_reader/backends/yaml_file.rb', line 15

def get(path)
  parts = decompose_path(path)
  get_value_from_hash(@data, parts)
end