Module: RecursiveHashUtils
- Defined in:
- lib/recursive-hash-utils.rb
Class Method Summary collapse
Class Method Details
.convert_string_keys_to_symbols(hash) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/recursive-hash-utils.rb', line 2 def self.convert_string_keys_to_symbols hash s2s = lambda do |h| if Hash === h Hash[ h.map do |k, v| [k.respond_to?(:to_sym) ? k.to_sym : k, s2s[v]] end ] elsif Array === h hash_array = [] h.each do |val| hash_array.push s2s[val] end hash_array else h end end s2s[hash] end |