Class: EasySettings::YamlSource
- Inherits:
-
Object
- Object
- EasySettings::YamlSource
- Defined in:
- lib/easy-settings/yaml_source.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path) ⇒ YamlSource
constructor
A new instance of YamlSource.
- #load ⇒ Object
Constructor Details
#initialize(path) ⇒ YamlSource
Returns a new instance of YamlSource.
7 8 9 |
# File 'lib/easy-settings/yaml_source.rb', line 7 def initialize(path) @path = path.to_s end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/easy-settings/yaml_source.rb', line 5 def path @path end |
Instance Method Details
#load ⇒ Object
11 12 13 14 15 |
# File 'lib/easy-settings/yaml_source.rb', line 11 def load File.exist?(path) ? (YAML.load(ERB.new(IO.read(path)).result) || {}) : {} rescue StandardError => e raise "Error occurred while parsing #{path}: #{e.}" end |