Class: Datadog::Configuration::Option
- Inherits:
-
Object
- Object
- Datadog::Configuration::Option
- Defined in:
- lib/ddtrace/configuration/option.rb
Overview
Represents an instance of an integration configuration option
Instance Attribute Summary collapse
-
#definition ⇒ Object
readonly
Returns the value of attribute definition.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(definition, context) ⇒ Option
constructor
A new instance of Option.
- #reset ⇒ Object
- #set(value) ⇒ Object
Constructor Details
#initialize(definition, context) ⇒ Option
Returns a new instance of Option.
8 9 10 11 12 13 |
# File 'lib/ddtrace/configuration/option.rb', line 8 def initialize(definition, context) @definition = definition @context = context @value = nil @is_set = false end |
Instance Attribute Details
#definition ⇒ Object (readonly)
Returns the value of attribute definition.
5 6 7 |
# File 'lib/ddtrace/configuration/option.rb', line 5 def definition @definition end |
Instance Method Details
#get ⇒ Object
21 22 23 24 |
# File 'lib/ddtrace/configuration/option.rb', line 21 def get return definition.default_value unless @is_set @value end |
#reset ⇒ Object
26 27 28 29 |
# File 'lib/ddtrace/configuration/option.rb', line 26 def reset @is_set = false @value = nil end |
#set(value) ⇒ Object
15 16 17 18 19 |
# File 'lib/ddtrace/configuration/option.rb', line 15 def set(value) @value = @context.instance_exec(value, &definition.setter).tap do @is_set = true end end |