module RecursiveHashUtils

Public Class Methods

convert_string_keys_to_symbols(hash) click to toggle source
# File lib/recursive-hash-utils.rb, line 2
def self.convert_string_keys_to_symbols hash
  warn "[DEPRECATION] This gem has been renamed to 'masteryconnect-automation-utils' and will no longer be supported. Please switch to 'masteryconnect-automation-utils' as soon as possible."

  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