Sha256: 1a55d8b72101c7af72e089094eec723ec28792861f7d391927a4e756bb4138be

Contents?: true

Size: 485 Bytes

Versions: 34

Compression:

Stored size: 485 Bytes

Contents

# Collection of utility methods for the Hash object
class HashUtil
  
  # Returns a hash with the keys converted to symbols
  def self.deep_symbolize_keys(hash)
    raise "Cannot symbolize keys for a nil object" if hash.nil?
    hash.keys.each do |key|
      value = hash[key]
      hash.delete(key)
      hash[key.to_sym] = value
      if hash[key.to_sym].instance_of? Hash
        hash[key.to_sym] = HashUtil.deep_symbolize_keys(hash[key.to_sym])
      end
    end
    hash
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
cobweb-1.2.1 lib/hash_util.rb
cobweb-1.2.0 lib/hash_util.rb
cobweb-1.1.0 lib/hash_util.rb
cobweb-1.0.29 lib/hash_util.rb
cobweb-1.0.28 lib/hash_util.rb
cobweb-1.0.27 lib/hash_util.rb
cobweb-1.0.26 lib/hash_util.rb
cobweb-1.0.25 lib/hash_util.rb
cobweb-1.0.24 lib/hash_util.rb
cobweb-1.0.23 lib/hash_util.rb
cobweb-1.0.22 lib/hash_util.rb
cobweb-1.0.21 lib/hash_util.rb
cobweb-1.0.20 lib/hash_util.rb
cobweb-1.0.19 lib/hash_util.rb
cobweb-1.0.18 lib/hash_util.rb
cobweb-1.0.17 lib/hash_util.rb
cobweb-1.0.16 lib/hash_util.rb
cobweb-1.0.15 lib/hash_util.rb
cobweb-1.0.12 lib/hash_util.rb
cobweb-1.0.11 lib/hash_util.rb