Sha256: 3ab17480b50cb8e8d13c1e106ae7ba1faa6462d2d9328b352c3ad494a00af7eb
Contents?: true
Size: 606 Bytes
Versions: 5
Compression:
Stored size: 606 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! self.replace(self.symbolize_keys) end # Delegation def method_missing(key) self.symbolize_keys[key.to_sym] end end end end Hash.send :include, Aurb::CoreExt::Hash
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
aurb-1.3.0 | lib/aurb/core_ext/hash.rb |
aurb-1.2.4 | lib/aurb/core_ext/hash.rb |
aurb-1.2.3 | lib/aurb/core_ext/hash.rb |
aurb-1.2.2 | lib/aurb/core_ext/hash.rb |
aurb-1.2.1 | lib/aurb/core_ext/hash.rb |