Module: YAML
- Defined in:
- lib/yaml_extend.rb
Overview
Extending the YAML library to allow to inherit from another YAML file(s)
Constant Summary collapse
- DEFAULT_INHERITANCE_KEY =
default path in the yaml file where the files to inherit from are defined
'extends'
- @@ext_load_key =
nil
Class Method Summary collapse
-
.ext_load_file(yaml_path, inheritance_key = nil, extend_existing_arrays = true) ⇒ Hash
Extended variant of the YAML.load_file method by providing the ability to inherit from other YAML file(s).
-
.ext_load_key=(key) ⇒ Object
Set a custom inheritance key globally once.
-
.reset_load_key ⇒ Object
Reset the ext_load_key and use the default settings.
Class Method Details
.ext_load_file(yaml_path, inheritance_key = nil, extend_existing_arrays = true) ⇒ Hash
Extended variant of the YAML.load_file method by providing the ability to inherit from other YAML file(s)
45 46 47 |
# File 'lib/yaml_extend.rb', line 45 def self.ext_load_file(yaml_path, inheritance_key=nil, extend_existing_arrays=true) YAML.ext_load_file_recursive(yaml_path, inheritance_key, extend_existing_arrays, {}) end |
.ext_load_key=(key) ⇒ Object
Set a custom inheritance key globally once. So you don’t need to specify it on every call of ext_load_file()
21 22 23 24 25 26 27 |
# File 'lib/yaml_extend.rb', line 21 def self.ext_load_key=(key) if key.is_a?(String) || key.is_a?(Array) || key.nil? @@ext_load_key = key else raise "Parameter 'key' must be of type String or Array<String> or nil" end end |
.reset_load_key ⇒ Object
Reset the ext_load_key and use the default settings
32 33 34 |
# File 'lib/yaml_extend.rb', line 32 def self.reset_load_key() @@ext_load_key = nil end |