Sha256: 296d8ba4b130db58afc35764b7b7f07cb1660c3d9ef217f7cd6623c95e1bcf07

Contents?: true

Size: 361 Bytes

Versions: 3

Compression:

Stored size: 361 Bytes

Contents

# Extensions to the core Hash class.
class Hash
  # Turn all string keys into symbols.  Returns the modified hash.
  def symbolize_keys
    inject({}) do |options, (key, value)|
      options[key.to_sym || key] = value
      options
    end
  end

  # Destructive version of symbolize_keys.
  def symbolize_keys!
    self.replace(self.symbolize_keys)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
git-trip-0.0.3 lib/core_ext/hash.rb
git-trip-0.0.4 lib/core_ext/hash.rb
git-trip-0.0.5 lib/core_ext/hash.rb