Sha256: 5fafbea7457eb096de4cf99fbfdf4bab079361129d69d4548ccff88fc36754a1

Contents?: true

Size: 646 Bytes

Versions: 38

Compression:

Stored size: 646 Bytes

Contents

module Honeybadger
  # @api private
  module Conversions
    module_function
    MAX_CONTEXT_DEPTH = 5

    # Convert context into a Hash.
    #
    # @param [Object] object The context object.
    #
    # @return [Hash] The hash context.
    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
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
honeybadger-5.24.0 lib/honeybadger/conversions.rb
honeybadger-5.23.0 lib/honeybadger/conversions.rb
honeybadger-5.22.0 lib/honeybadger/conversions.rb
honeybadger-5.21.0 lib/honeybadger/conversions.rb
honeybadger-5.20.1 lib/honeybadger/conversions.rb
honeybadger-5.20.0 lib/honeybadger/conversions.rb
honeybadger-5.19.2 lib/honeybadger/conversions.rb
honeybadger-5.19.1 lib/honeybadger/conversions.rb
honeybadger-5.19.0 lib/honeybadger/conversions.rb
honeybadger-5.18.0 lib/honeybadger/conversions.rb
honeybadger-5.17.0 lib/honeybadger/conversions.rb
honeybadger-5.16.0 lib/honeybadger/conversions.rb
honeybadger-5.15.6 lib/honeybadger/conversions.rb
honeybadger-5.15.5 lib/honeybadger/conversions.rb
honeybadger-5.15.4 lib/honeybadger/conversions.rb
honeybadger-5.15.3 lib/honeybadger/conversions.rb
honeybadger-5.15.2 lib/honeybadger/conversions.rb
honeybadger-5.15.1 lib/honeybadger/conversions.rb
honeybadger-5.15.0 lib/honeybadger/conversions.rb
honeybadger-5.14.2 lib/honeybadger/conversions.rb