Sha256: 17bca033f1cd8b039178fe78dfc249e29d451f720647a3f4bde2de109084cb69

Contents?: true

Size: 771 Bytes

Versions: 5

Compression:

Stored size: 771 Bytes

Contents

# typed: true
module Datadog
  module Configuration
    # PinSetup translates a flat hash into a Pin configuration
    # This class should be removed if we ever remove/refactor the Pin class
    class PinSetup
      def initialize(target, opts = {})
        @pin = Pin.get_from(target)
        @opts = opts
      end

      def call
        return unless pin

        ATTRS.each { |key| pin.public_send("#{key}=", opts[key]) if opts[key] }

        pin.config = opts.reject { |key, _| ATTRS.include?(key) || DEPRECATED_ATTRS.include?(key) }

        true
      end

      private

      attr_reader :pin, :opts

      ATTRS = [:app, :tags, :app_type, :name, :service_name].freeze
      DEPRECATED_ATTRS = [:tracer].freeze

      private_constant :ATTRS
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-0.54.2 lib/ddtrace/configuration/pin_setup.rb
ddtrace-0.54.1 lib/ddtrace/configuration/pin_setup.rb
ddtrace-0.54.0 lib/ddtrace/configuration/pin_setup.rb
ddtrace-0.53.0 lib/ddtrace/configuration/pin_setup.rb
ddtrace-0.52.0 lib/ddtrace/configuration/pin_setup.rb