Class: Datadog::Configuration::PinSetup

Inherits:
Object
  • Object
show all
Defined in:
lib/ddtrace/configuration/pin_setup.rb

Overview

PinSetup translates a flat hash into a Pin configuration This class should be removed if we ever remove/refactor the Pin class

Instance Method Summary collapse

Constructor Details

#initialize(target, opts = {}) ⇒ PinSetup

Returns a new instance of PinSetup.



7
8
9
10
# File 'lib/ddtrace/configuration/pin_setup.rb', line 7

def initialize(target, opts = {})
  @pin = Pin.get_from(target)
  @opts = opts
end

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
# File 'lib/ddtrace/configuration/pin_setup.rb', line 12

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