class Thumbtack::HashToDigest

Handles renaming the hash attribute to digest from response hashes. This is required in order to avoid collisions with the `Object#hash` method.

@api private

Constants

DIGEST
HASH

Public Class Methods

rename(hash) click to toggle source

Rename any attribute called hash to digest

@example

HashToDigest.rename('hash' => '1234')  # => { 'digest' => '1234' }

@param [Hash{String => Object}] hash

the response hash

@return [Hash{String => Object}]

a hash with any key 'hash' renamed to 'digest'
# File lib/thumbtack/hash_to_digest.rb, line 22
def self.rename(hash)
  attrs = hash.dup
  digest = attrs.delete(HASH)
  attrs.merge(DIGEST => digest)
end