Class: Datadog::Core::Remote::Configuration::Content

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

Overview

Content stores the information associated with a specific Configuration::Path

Defined Under Namespace

Modules: ApplyState

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, data:) ⇒ Content

Returns a new instance of Content.



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

def initialize(path:, data:)
  @path = path
  @data = data
  @apply_state = ApplyState::UNACKNOWLEDGED
  @apply_error = nil
  @hashes = {}
  @version = 0
end

Instance Attribute Details

#apply_errorObject (readonly)

Returns the value of attribute apply_error.



21
22
23
# File 'lib/datadog/core/remote/configuration/content.rb', line 21

def apply_error
  @apply_error
end

#apply_stateObject (readonly)

Returns the value of attribute apply_state.



21
22
23
# File 'lib/datadog/core/remote/configuration/content.rb', line 21

def apply_state
  @apply_state
end

#dataObject (readonly)

Returns the value of attribute data.



21
22
23
# File 'lib/datadog/core/remote/configuration/content.rb', line 21

def data
  @data
end

#hashesObject (readonly)

Returns the value of attribute hashes.



21
22
23
# File 'lib/datadog/core/remote/configuration/content.rb', line 21

def hashes
  @hashes
end

#pathObject (readonly)

Returns the value of attribute path.



21
22
23
# File 'lib/datadog/core/remote/configuration/content.rb', line 21

def path
  @path
end

#versionObject

Returns the value of attribute version.



22
23
24
# File 'lib/datadog/core/remote/configuration/content.rb', line 22

def version
  @version
end

Class Method Details

.parse(hash) ⇒ Object



13
14
15
16
17
18
# File 'lib/datadog/core/remote/configuration/content.rb', line 13

def parse(hash)
  path = Path.parse(hash[:path])
  data = hash[:content]

  new(path: path, data: data)
end

Instance Method Details

#appliedObject

Sets this configuration as successfully applied.



42
43
44
45
# File 'lib/datadog/core/remote/configuration/content.rb', line 42

def applied
  @apply_state = ApplyState::ACKNOWLEDGED
  @apply_error = nil
end

#errored(error_message) ⇒ Object

Sets this configuration as not successfully applied, with a message describing the error.



49
50
51
52
# File 'lib/datadog/core/remote/configuration/content.rb', line 49

def errored(error_message)
  @apply_state = ApplyState::ERROR
  @apply_error = error_message
end

#hexdigest(type) ⇒ Object



33
34
35
# File 'lib/datadog/core/remote/configuration/content.rb', line 33

def hexdigest(type)
  @hashes[type] || compute_and_store_hash(type)
end

#lengthObject



37
38
39
# File 'lib/datadog/core/remote/configuration/content.rb', line 37

def length
  @length ||= @data.size
end