Sha256: e31e07eda7917929830bf7594b980c7b172904f81a506904ca94eeb4cd340558
Contents?: true
Size: 590 Bytes
Versions: 2
Compression:
Stored size: 590 Bytes
Contents
#!/usr/bin/env ruby # encoding: utf-8 module Aurb module CoreExt module Hash # Returns a new hash with all keys converted to symbols. def symbolize_keys inject({}) do |options, (key, value)| options[(key.to_sym rescue key) || key] = value options end end # Destructively converts all keys to symbols. def symbolize_keys! replace symbolize_keys end # Delegation def method_missing(key) symbolize_keys[key.to_sym] end end end end Hash.send :include, Aurb::CoreExt::Hash
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
aurb-1.4.1 | lib/aurb/core_ext/hash.rb |
aurb-1.4.0 | lib/aurb/core_ext/hash.rb |