Module: Datadog::Core::Configuration::Options::ClassMethods

Defined in:
lib/datadog/core/configuration/options.rb

Overview

Class behavior for a configuration object with options

Instance Method Summary collapse

Instance Method Details

#optionsObject



47
48
49
50
51
52
53
54
# File 'lib/datadog/core/configuration/options.rb', line 47

def options
  # Allows for class inheritance of option definitions
  @options ||= if superclass <= Options
    superclass.options.dup
  else
    {}
  end
end

#settings_childrenObject

Registry of nested settings classes keyed by the option name declared via Base.settings. This lets us propagate a new settings path down the tree without storing parent references on the nested class or on the option definition itself.



27
28
29
30
31
32
33
# File 'lib/datadog/core/configuration/options.rb', line 27

def settings_children
  @settings_children ||= if superclass <= Options
    superclass.settings_children.dup
  else
    {}
  end
end

#settings_pathObject



19
20
21
# File 'lib/datadog/core/configuration/options.rb', line 19

def settings_path
  defined?(@settings_path) ? @settings_path : nil
end

#settings_path=(path) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/datadog/core/configuration/options.rb', line 35

def settings_path=(path)
  @settings_path = path

  # Keep nested settings paths in sync when a parent settings path is
  # assigned later, which is how contrib integrations inject
  # "tracing.<integration>" into their configuration classes.
  settings_children.each do |name, settings_class|
    nested_settings_path = path ? "#{path}.#{name}" : name.to_s
    settings_class.settings_path = nested_settings_path
  end
end