Sha256: 99994b9df5e3ca8174a95f30f33522d7a719365145e04ed0bdbf24216fa89f30

Contents?: true

Size: 329 Bytes

Versions: 2

Compression:

Stored size: 329 Bytes

Contents

class Hash

  # Return self as symbolized keys hash
  def symbolize_keys
    self.dup.inject({}) do |hsh, (k,v)|
      hsh[k.to_sym] = (v.respond_to?(:symbolize_keys) ? v.symbolize_keys : v)
      hsh
    end
  end

  # Replace self with symbolized keys hash
  def symbolize_keys!
    self.replace(self.symbolize_keys)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fozzie-0.0.2 lib/core_ext/hash.rb
fozzie-0.0.1 lib/core_ext/hash.rb