Module: Honeybadger::Conversions Private

Included in:
ContextManager, Notice
Defined in:
lib/honeybadger/conversions.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Constant Summary collapse

MAX_CONTEXT_DEPTH =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

5

Class Method Summary collapse

Class Method Details

.Context(object, depth = 1) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Convert context into a Hash.

Parameters:

  • object (Object)

    The context object.

Returns:

  • (Hash)

    The hash context.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/honeybadger/conversions.rb', line 12

def Context(object, depth = 1)
  object = object.to_honeybadger_context if object.respond_to?(:to_honeybadger_context)
  object = Hash(object)
  object = object.transform_values do |value|
    if value&.respond_to?(:to_honeybadger_context)
      Context(value, depth + 1)
    else
      value
    end
  end if depth < MAX_CONTEXT_DEPTH
  object
end