Class: Datadog::Configuration::OptionDefinition

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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, 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.



9
10
11
# File 'lib/ddtrace/configuration/option_definition.rb', line 9

def default
  @default
end

#delegate_toObject (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_onObject (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

#lazyObject (readonly)

Returns the value of attribute lazy.



9
10
11
# File 'lib/ddtrace/configuration/option_definition.rb', line 9

def lazy
  @lazy
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/ddtrace/configuration/option_definition.rb', line 9

def name
  @name
end

#on_setObject (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

#resetterObject (readonly)

Returns the value of attribute resetter.



9
10
11
# File 'lib/ddtrace/configuration/option_definition.rb', line 9

def resetter
  @resetter
end

#setterObject (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_valueObject



30
31
32
# File 'lib/ddtrace/configuration/option_definition.rb', line 30

def default_value
  lazy ? @default.call : @default
end