Class: Hash

Inherits:
Object
  • Object
show all
Includes:
Metanorma::Utils::Hash
Defined in:
lib/metanorma/cli/stringify_all_keys.rb

Instance Method Summary collapse

Instance Method Details

#stringify_all_keysObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/metanorma/cli/stringify_all_keys.rb', line 26

def stringify_all_keys
  result = {}
  each do |k, v|
    result[k.to_s] = case v
                     when Hash, Array
                       v.stringify_all_keys
                     else
                       v
                     end
  end
  result
end

#symbolize_all_keysObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/metanorma/cli/stringify_all_keys.rb', line 39

def symbolize_all_keys
  result = {}
  each do |k, v|
    result[k.to_sym] = case v
                       when Hash, Array
                         v.symbolize_all_keys
                       else
                         v
                       end
  end
  result
end