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 Conetnt instances It provides convinient methods for finding content base on Configuration::Path and Configuration::Target

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse(array) ⇒ Object



79
80
81
# File 'lib/datadog/core/remote/configuration/content.rb', line 79

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

Instance Method Details

#[](path) ⇒ Object



88
89
90
# File 'lib/datadog/core/remote/configuration/content.rb', line 88

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

#[]=(path, content) ⇒ Object



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

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

#delete(path) ⇒ Object



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

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

  return if idx.nil?

  delete_at(idx)
end

#find_content(path, target) ⇒ Object



84
85
86
# File 'lib/datadog/core/remote/configuration/content.rb', line 84

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

#pathsObject



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

def paths
  map(&:path).uniq
end