Sha256: 75879ff2871ba6a5d0387d6eb830ba0dc921d8c83c1c14be26ad6b0b5c59a689

Contents?: true

Size: 334 Bytes

Versions: 25

Compression:

Stored size: 334 Bytes

Contents

class Hash

  # Return self as symbolized keys hash
  def symbolize_keys
    self.dup.inject({}) do |hsh, (k,v)|
      hsh[k.to_s.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

25 entries across 25 versions & 1 rubygems

Version Path
fozzie-0.0.7 lib/core_ext/hash.rb
fozzie-0.0.6 lib/core_ext/hash.rb
fozzie-0.0.5 lib/core_ext/hash.rb
fozzie-0.0.4 lib/core_ext/hash.rb
fozzie-0.0.3 lib/core_ext/hash.rb