Class: Datadog::Configuration::OptionDefinition
- Inherits:
-
Object
- Object
- Datadog::Configuration::OptionDefinition
- Defined in:
- lib/ddtrace/configuration/option_definition.rb
Overview
Represents a definition for an integration configuration option
Defined Under Namespace
Classes: Builder
Constant Summary collapse
- IDENTITY =
->(x) { x }
Instance Attribute Summary collapse
-
#default ⇒ Object
readonly
Returns the value of attribute default.
-
#delegate_to ⇒ Object
readonly
Returns the value of attribute delegate_to.
-
#depends_on ⇒ Object
readonly
Returns the value of attribute depends_on.
-
#lazy ⇒ Object
readonly
Returns the value of attribute lazy.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#on_set ⇒ Object
readonly
Returns the value of attribute on_set.
-
#resetter ⇒ Object
readonly
Returns the value of attribute resetter.
-
#setter ⇒ Object
readonly
Returns the value of attribute setter.
Instance Method Summary collapse
-
#build(context) ⇒ Object
Creates a new Option, bound to the context provided.
- #default_value ⇒ Object
-
#initialize(name, meta = {}, &block) ⇒ OptionDefinition
constructor
A new instance of OptionDefinition.
Constructor Details
#initialize(name, meta = {}, &block) ⇒ OptionDefinition
Returns a new instance of OptionDefinition.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 19 def initialize(name, = {}, &block) @default = [:default] @delegate_to = [:delegate_to] @depends_on = [:depends_on] || [] @lazy = [:lazy] || false @name = name.to_sym @on_set = [:on_set] @resetter = [:resetter] @setter = [:setter] || block || IDENTITY end |
Instance Attribute Details
#default ⇒ Object (readonly)
Returns the value of attribute default.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def default @default end |
#delegate_to ⇒ Object (readonly)
Returns the value of attribute delegate_to.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def delegate_to @delegate_to end |
#depends_on ⇒ Object (readonly)
Returns the value of attribute depends_on.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def depends_on @depends_on end |
#lazy ⇒ Object (readonly)
Returns the value of attribute lazy.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def lazy @lazy end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def name @name end |
#on_set ⇒ Object (readonly)
Returns the value of attribute on_set.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def on_set @on_set end |
#resetter ⇒ Object (readonly)
Returns the value of attribute resetter.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def resetter @resetter end |
#setter ⇒ Object (readonly)
Returns the value of attribute setter.
9 10 11 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 9 def setter @setter end |
Instance Method Details
#build(context) ⇒ Object
Creates a new Option, bound to the context provided.
35 36 37 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 35 def build(context) Option.new(self, context) end |
#default_value ⇒ Object
30 31 32 |
# File 'lib/ddtrace/configuration/option_definition.rb', line 30 def default_value lazy ? @default.call : @default end |