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



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

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

Instance Method Details

#[](path) ⇒ Object



59
60
61
# File 'lib/datadog/core/remote/configuration/content.rb', line 59

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

#[]=(path, content) ⇒ Object



63
64
65
# File 'lib/datadog/core/remote/configuration/content.rb', line 63

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

#delete(path) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/datadog/core/remote/configuration/content.rb', line 67

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

  return if idx.nil?

  delete_at(idx)
end

#find_content(path, target) ⇒ Object



55
56
57
# File 'lib/datadog/core/remote/configuration/content.rb', line 55

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

#pathsObject



75
76
77
# File 'lib/datadog/core/remote/configuration/content.rb', line 75

def paths
  map(&:path).uniq
end