module Contacts::Util

Public Class Methods

frozen_hash(hash={}) click to toggle source

Freeze the given hash, and any hash values recursively.

# 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) click to toggle source

Return a copy of hash with the keys turned into Symbols.

# 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