Top Level Namespace

Defined Under Namespace

Modules: AlintaTesting Classes: Hash

Instance Method Summary collapse

Instance Method Details

#parse_attributes(hashes) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/alinta-testing/overrides.rb', line 13

def parse_attributes(hashes)
  hashes.each_with_object({}) do |row, hash|
    name = row['attribute']
    value = row['value']
    type = row['type']
    # this condition is new and allows the value to be resolved from ruby code

    if type == 'expression'
      value = eval(value) 
    else
      value = resolve_functions(value)
      value = resolve(value)
      value.gsub!(/\\n/, "\n")
      value = string_to_type(value, type)
    end
    names = split_fields(name)
    new_hash = names.reverse.inject(value) { |a, n| add_to_hash(a, n) }
    hash.deep_merge!(new_hash) { |_, old, new| new.is_a?(Array) ? merge_arrays(old, new) : new }
  end
end