Module: ReamazeAPI::Utils

Extended by:
Utils
Included in:
Utils
Defined in:
lib/reamaze_api/utils.rb,
lib/reamaze_api/utils/hash_keys.rb

Defined Under Namespace

Modules: HashKeys

Instance Method Summary collapse

Instance Method Details

#error_hash(exception) ⇒ Object

Hash used for error responses.

Parameters:

  • exception

    An Exception instance

Returns:

  • a Hash.



21
22
23
24
25
26
27
28
29
# File 'lib/reamaze_api/utils.rb', line 21

def error_hash(exception)
  {
    success: false,
    payload: {
      error:   exception.class.name,
      message: exception.message
    }
  }
end

#symbolize_hash(hash) ⇒ Object

Deep-symbolize keys in the given Hash.

Parameters:

  • hash

    a Hash instance

Returns:

  • a Hash.



12
13
14
# File 'lib/reamaze_api/utils.rb', line 12

def symbolize_hash(hash)
  HashKeys.deep_symbolize_keys(hash)
end