Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/price_hubble/core_ext/hash.rb

Overview

All our Ruby core extensions for the Hash class.

Instance Method Summary collapse

Instance Method Details

#deep_camelize_keysHash

Perform a deep key transformation on the hash, so all keys are in camelcase.

Returns:



17
18
19
# File 'lib/price_hubble/core_ext/hash.rb', line 17

def deep_camelize_keys
  deep_transform_keys { |key| key.to_s.camelize(:lower) }
end

#deep_compactHash

Perform the regular Hash#compact method on the object but takes care of deeply nested hashs.

Returns:



9
10
11
# File 'lib/price_hubble/core_ext/hash.rb', line 9

def deep_compact
  deep_compact_in_object(self)
end

#deep_underscore_keysHash

Perform a deep key transformation on the hash, so all keys are in snakecase/underscored.

Returns:



25
26
27
# File 'lib/price_hubble/core_ext/hash.rb', line 25

def deep_underscore_keys
  deep_transform_keys { |key| key.to_s.underscore }
end