Module: SimpleJSONAPIClient::Utils

Defined in:
lib/simple_jsonapi_client/utils.rb

Class Method Summary collapse

Class Method Details

.hash_dig(hash, *keys) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/simple_jsonapi_client/utils.rb', line 15

def hash_dig(hash, *keys)
  if hash.respond_to?(:dig)
    hash.dig(*keys)
  else
    dig(hash, keys)
  end
end

.symbolize_keys(hash) ⇒ Object

Implementation adapted from ActiveSupport Copyright © 2005-2019 David Heinemeier Hansson github.com/rails/rails/blob/b9ca94caea2ca6a6cc09abaffaad67b447134079/activesupport/lib/active_support/core_ext/hash/keys.rb



7
8
9
10
11
12
13
# File 'lib/simple_jsonapi_client/utils.rb', line 7

def symbolize_keys(hash)
  result = {}
  hash.each_key do |key|
    result[(key.to_sym rescue key)] = hash[key]
  end
  result
end