Module: AppStoreConnectApi::Utils::HashUtils

Defined in:
lib/app_store_connect_api/utils/hash_utils.rb

Class Method Summary collapse

Class Method Details

.deep_transform_keys(object, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/app_store_connect_api/utils/hash_utils.rb', line 7

def deep_transform_keys(object, &block)
  case object
  when Hash
    object.each_with_object({}) do |(key, value), result|
      result[yield(key)] = deep_transform_keys value, &block
    end
  when Array
    object.map { |item| deep_transform_keys item, &block }
  else
    object
  end
end