Class: Hash

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
lib/core-extensions/hash_ext.rb,
lib/core-extensions/hash_ext.rb

Instance Method Summary collapse

Instance Method Details

#calculate_stable_hashableObject



21
22
23
# File 'lib/core-extensions/hash_ext.rb', line 21

def calculate_stable_hashable
  map { |k,v| "#{k.inspect}:#{v.inspect}" }.sort.join("//")
end

#stringify_keysObject



4
5
6
7
8
# File 'lib/core-extensions/hash_ext.rb', line 4

def stringify_keys
  r = []
  each { |k,v| r << k.to_s << v }
  Hash[*r]
end

#symbolize_keysObject



10
11
12
13
14
# File 'lib/core-extensions/hash_ext.rb', line 10

def symbolize_keys
  r = []
  each { |k,v| r << (k.respond_to?(:to_sym) ? k.to_sym : k) << v }
  Hash[*r]
end