Class: Datadog::Core::Remote::Configuration::ContentList

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

Overview

ContentList stores a list of Content instances. It provides convenient methods for finding content based on Configuration::Path and Configuration::Target.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(array) ⇒ Object



92
93
94
# File 'lib/datadog/core/remote/configuration/content.rb', line 92

def parse(array)
  new.concat(array.map { |c| Content.parse(c) })
end

Instance Method Details

#[](path) ⇒ Object



101
102
103
# File 'lib/datadog/core/remote/configuration/content.rb', line 101

def [](path)
  find { |c| c.path.eql?(path) }
end

#[]=(path, content) ⇒ Object



105
106
107
# File 'lib/datadog/core/remote/configuration/content.rb', line 105

def []=(path, content)
  map! { |c| c.path.eql?(path) ? content : c }
end

#delete(path) ⇒ Object



109
110
111
112
113
114
115
# File 'lib/datadog/core/remote/configuration/content.rb', line 109

def delete(path)
  idx = index { |e| e.path.eql?(path) }

  return if idx.nil?

  delete_at(idx)
end

#find_content(path, target) ⇒ Object



97
98
99
# File 'lib/datadog/core/remote/configuration/content.rb', line 97

def find_content(path, target)
  find { |c| c.path.eql?(path) && target.check(c) }
end

#pathsObject



117
118
119
# File 'lib/datadog/core/remote/configuration/content.rb', line 117

def paths
  map(&:path).uniq
end