Module: ConfigVolumizer::Parser

Defined in:
lib/config_volumizer/parser.rb

Class Method Summary collapse

Class Method Details

.parse(source, mapping) ⇒ Hash

Parses keys within the source hash matching base_name returning a hash with all the matched data under a string key matching the base_name

See Readme for an example

Parameters:

  • source (Hash)
  • mapping (Hash)

Returns:

  • (Hash)


18
19
20
21
22
23
24
25
26
27
28
# File 'lib/config_volumizer/parser.rb', line 18

def parse(source, mapping)
  result = {}
  mapping.each do |mapping_key, mapping_info|
    source.each do |key, value|
      if matches_name(mapping_key, key)
        handle_item(result, key, value, mapping_key, mapping_info)
      end
    end
  end
  result
end