Module: RightSupport::Config::YAMLConfig
- Defined in:
- lib/right_support/config/yaml_config.rb
Overview
Helper that encapsulates logic for loading YAML configuration hashes from various sources which can include strings, IO objects, or already-loaded YAML in the form of a Hash.
Class Method Summary collapse
-
.read(something) ⇒ Object
Load yaml source.
Class Method Details
.read(something) ⇒ Object
Load yaml source
Parameters
- something(IO|String|Hash)
-
File path, IO, raw YAML string, or a pre-loaded Hash
Returns
- (Boolean|Hash)
-
Loaded yaml file or false if a RuntimeError occurred while loading
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/right_support/config/yaml_config.rb', line 39 def read(something) return_value = false begin if something.kind_of?(Hash) return_value = something elsif File.exists?(something) return_value = YAML.load_file(something) else return_value = YAML.load(something) end raise unless return_value.kind_of?(Hash) rescue return_value = false end return_value end |