Class: Datadog::Core::Configuration::OptionDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog/core/configuration/option_definition.rb

Overview

Represents a definition for an integration configuration option

Defined Under Namespace

Classes: Builder

Constant Summary collapse

IDENTITY =
->(new_value, _old_value) { new_value }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, meta = {}, &block) ⇒ OptionDefinition

Returns a new instance of OptionDefinition.



22
23
24
25
26
27
28
29
30
31
# File 'lib/datadog/core/configuration/option_definition.rb', line 22

def initialize(name, meta = {}, &block)
  @default = meta[:default]
  @delegate_to = meta[:delegate_to]
  @depends_on = meta[:depends_on] || []
  @lazy = meta[:lazy] || false
  @name = name.to_sym
  @on_set = meta[:on_set]
  @resetter = meta[:resetter]
  @setter = meta[:setter] || block || IDENTITY
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def default
  @default
end

#delegate_toObject (readonly)

Returns the value of attribute delegate_to.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def delegate_to
  @delegate_to
end

#depends_onObject (readonly)

Returns the value of attribute depends_on.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def depends_on
  @depends_on
end

#lazyObject (readonly)

Returns the value of attribute lazy.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def lazy
  @lazy
end

#nameObject (readonly)

Returns the value of attribute name.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def name
  @name
end

#on_setObject (readonly)

Returns the value of attribute on_set.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def on_set
  @on_set
end

#resetterObject (readonly)

Returns the value of attribute resetter.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def resetter
  @resetter
end

#setterObject (readonly)

Returns the value of attribute setter.



12
13
14
# File 'lib/datadog/core/configuration/option_definition.rb', line 12

def setter
  @setter
end

Instance Method Details

#build(context) ⇒ Object

Creates a new Option, bound to the context provided.



34
35
36
# File 'lib/datadog/core/configuration/option_definition.rb', line 34

def build(context)
  Option.new(self, context)
end