Module: Contacts::Util
- Defined in:
- lib/contacts/util.rb
Class Method Summary collapse
-
.frozen_hash(hash = {}) ⇒ Object
Freeze the given hash, and any hash values recursively.
-
.symbolize_keys(hash) ⇒ Object
Return a copy of
hash
with the keys turned into Symbols.
Class Method Details
.frozen_hash(hash = {}) ⇒ Object
Freeze the given hash, and any hash values recursively.
6 7 8 9 10 11 |
# File 'lib/contacts/util.rb', line 6 def self.frozen_hash(hash={}) hash.freeze hash.keys.each{|k| k.freeze} hash.values.each{|v| v.freeze} hash end |
.symbolize_keys(hash) ⇒ Object
Return a copy of hash
with the keys turned into Symbols.
16 17 18 19 20 21 22 |
# File 'lib/contacts/util.rb', line 16 def self.symbolize_keys(hash) result = {} hash.each do |key, value| result[key.to_sym] = value end result end |