Sha256: f801c2027e5a76b5dee14a32175746a8845054b416b54ce0b4de3f89d6061a0c

Contents?: true

Size: 303 Bytes

Versions: 3

Compression:

Stored size: 303 Bytes

Contents

class Hash

  def keys_to_sym
    self.keys.each do |key| 
      case self[key].class.to_s
      when "Hash"
        self[key].keys_to_sym
      when "Array"
        self[key].map {|el| el.is_a?(Hash) ? el.keys_to_sym : el}
      end
      self[key.to_sym] = self.delete(key)
    end
    self
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cotcube-helpers-0.1.3 lib/cotcube-helpers/hash_ext.rb
cotcube-helpers-0.1.2 lib/cotcube-helpers/hash_ext.rb
cotcube-helpers-0.1.1 lib/cotcube-helpers/hash_ext.rb