Method: AutomationObject::BluePrint::YamlAdapter.load_yaml_files

Defined in:
lib/automation_object/blue_print/yaml_adapter.rb

.load_yaml_files(file_array) ⇒ Hash

Returns merged YAML Hash.

Parameters:

  • array of file paths to load

Returns:

  • merged YAML Hash



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/automation_object/blue_print/yaml_adapter.rb', line 27

def load_yaml_files(file_array)
  merged_yaml_hash = {}

  file_array.each do |file_path|
    next unless yaml_file?(file_path)

    file_hash = YAML.load_file(file_path)

    raise "Expecting file #{file_path} to be a hash when loaded" unless file_hash.is_a?(Hash)

    merged_yaml_hash = merged_yaml_hash.deep_merge(file_hash)
  end

  merged_yaml_hash
end