Module: Datadog::Core::Configuration::Options::InstanceMethods

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

Overview

Instance behavior for a configuration object with options

Instance Method Summary collapse

Instance Method Details

#get_option(name) ⇒ Object



78
79
80
# File 'lib/datadog/core/configuration/options.rb', line 78

def get_option(name)
  resolve_option(name).get
end

#option_defined?(name) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/datadog/core/configuration/options.rb', line 87

def option_defined?(name)
  self.class.options.key?(name)
end

#optionsObject



66
67
68
# File 'lib/datadog/core/configuration/options.rb', line 66

def options
  @options ||= {}
end

#options_hashObject



97
98
99
100
101
# File 'lib/datadog/core/configuration/options.rb', line 97

def options_hash
  self.class.options.merge(options).each_with_object({}) do |(key, _), hash|
    hash[key] = get_option(key)
  end
end

#reset_option(name) ⇒ Object



82
83
84
85
# File 'lib/datadog/core/configuration/options.rb', line 82

def reset_option(name)
  assert_valid_option!(name)
  options[name].reset if options.key?(name)
end

#reset_options!Object



103
104
105
# File 'lib/datadog/core/configuration/options.rb', line 103

def reset_options!
  options.each_value(&:reset)
end

#set_option(name, value, precedence: Configuration::Option::Precedence::PROGRAMMATIC) ⇒ Object



70
71
72
# File 'lib/datadog/core/configuration/options.rb', line 70

def set_option(name, value, precedence: Configuration::Option::Precedence::PROGRAMMATIC)
  resolve_option(name).set(value, precedence: precedence)
end

#unset_option(name, precedence: Configuration::Option::Precedence::PROGRAMMATIC) ⇒ Object



74
75
76
# File 'lib/datadog/core/configuration/options.rb', line 74

def unset_option(name, precedence: Configuration::Option::Precedence::PROGRAMMATIC)
  resolve_option(name).unset(precedence)
end

#using_default?(name) ⇒ Boolean

Is this option’s value the default fallback value?

Returns:

  • (Boolean)


92
93
94
95
# File 'lib/datadog/core/configuration/options.rb', line 92

def using_default?(name)
  get_option(name) # Resolve value check if environment variable overwrote the default
  options[name].default_precedence?
end