Module: Datadog::Configurable::ClassMethods

Defined in:
lib/ddtrace/configurable.rb

Overview

ClassMethods

Instance Method Summary collapse

Instance Method Details

#get_option(name) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/ddtrace/configurable.rb', line 20

def get_option(name)
  __assert_valid!(name)

  return __default_value(name) unless __options[name][:set_flag]

  __options[name][:value]
end

#reset_options!Object



34
35
36
37
38
# File 'lib/ddtrace/configurable.rb', line 34

def reset_options!
  __options.each do |name, meta|
    set_option(name, meta[:default])
  end
end

#set_option(name, value) ⇒ Object



13
14
15
16
17
18
# File 'lib/ddtrace/configurable.rb', line 13

def set_option(name, value)
  __assert_valid!(name)

  __options[name][:value] = __options[name][:setter].call(value)
  __options[name][:set_flag] = true
end

#sorted_optionsObject



40
41
42
# File 'lib/ddtrace/configurable.rb', line 40

def sorted_options
  Configuration::Resolver.new(__dependency_graph).call
end

#to_hObject



28
29
30
31
32
# File 'lib/ddtrace/configurable.rb', line 28

def to_h
  __options.each_with_object({}) do |(key, _), hash|
    hash[key] = get_option(key)
  end
end