module Datadog::Configuration::Base::InstanceMethods

Instance methods for configuration

Public Class Methods

new(options = {}) click to toggle source
# File lib/ddtrace/configuration/base.rb, line 47
def initialize(options = {})
  configure(options) unless options.empty?
end

Public Instance Methods

configure(opts = {}) { |self| ... } click to toggle source
# File lib/ddtrace/configuration/base.rb, line 51
def configure(opts = {})
  # Sort the options in preference of dependency order first
  ordering = self.class.options.dependency_order
  sorted_opts = opts.sort_by do |name, _value|
    ordering.index(name) || (ordering.length + 1)
  end

  # Ruby 2.0 doesn't support Array#to_h
  sorted_opts = Hash[*sorted_opts.flatten]

  # Apply options in sort order
  sorted_opts.each do |name, value|
    if respond_to?("#{name}=")
      send("#{name}=", value)
    elsif option_defined?(name)
      set_option(name, value)
    end
  end

  # Apply any additional settings from block
  yield(self) if block_given?
end
reset!() click to toggle source
# File lib/ddtrace/configuration/base.rb, line 78
def reset!
  reset_options!
end
to_h() click to toggle source
# File lib/ddtrace/configuration/base.rb, line 74
def to_h
  options_hash
end