module Honeybadger::Conversions

@api private

Constants

MAX_CONTEXT_DEPTH

Public Instance Methods

Context(object, depth = 1) click to toggle source

Convert context into a Hash.

@param [Object] object The context object.

@return [Hash] The hash context.

# 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