Sha256: 0322c82145e6dc9bdf6e796abd9a0f8e95c77023d0700c74b992df90117b501e

Contents?: true

Size: 715 Bytes

Versions: 24

Compression:

Stored size: 715 Bytes

Contents

module Datadog
  module Contrib
    module Configuration
      # Represents an instance of an integration configuration option
      class Option
        attr_reader \
          :definition

        def initialize(definition, context)
          @definition = definition
          @context = context
          @value = nil
          @is_set = false
        end

        def set(value)
          @value = @context.instance_exec(value, &definition.setter).tap do
            @is_set = true
          end
        end

        def get
          return definition.default_value unless @is_set
          @value
        end

        def reset
          set(definition.default_value)
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ddtrace-0.20.0 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.19.1 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.19.0 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.18.3 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.18.2 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.18.1 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.18.0 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.17.3 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.17.2 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.17.1 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.17.0 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.16.1 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.15.0.internaltracinfeature1 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.16.0 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.14.2.disableprotocolversion4 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.15.0 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.14.2.withoutpriorityparsing1 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.14.2 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.14.1 lib/ddtrace/contrib/configuration/option.rb
ddtrace-0.15.0.beta1 lib/ddtrace/contrib/configuration/option.rb