class Hash
Public Instance Methods
array_aware_deep_symbolize_keys()
click to toggle source
transforms each String-key to Symbol-key
# File lib/ckick/hash.rb, line 26 def array_aware_deep_symbolize_keys array_aware_deep_transform_keys { |key| key.to_sym rescue key } end
array_aware_deep_transform_keys() { |key| ... }
click to toggle source
transforms keys recursively
-
block
- transform operation
# File lib/ckick/hash.rb, line 11 def array_aware_deep_transform_keys(&block) result = {} each do |key, value| new_key = yield(key) if value.is_a?(Hash) || value.is_a?(Array) result[new_key] = value.array_aware_deep_transform_keys(&block) else result[new_key] = value end end result end
without(*keys)
click to toggle source
copy of the hash without pairs of keys
# File lib/ckick/hash.rb, line 31 def without(*keys) dup.without!(*keys) end
without!(*keys)
click to toggle source
removes each pair of keys
# File lib/ckick/hash.rb, line 36 def without!(*keys) reject! { |key| keys.include?(key) } end