Class: Datadog::Contrib::Registry
- Inherits:
-
Object
- Object
- Datadog::Contrib::Registry
- Includes:
- Enumerable
- Defined in:
- lib/ddtrace/contrib/registry.rb
Overview
Registry is a collection of integrations.
Defined Under Namespace
Classes: Entry
Instance Method Summary collapse
- #[](name) ⇒ Object
- #add(name, klass, auto_patch = false) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
9 10 11 12 |
# File 'lib/ddtrace/contrib/registry.rb', line 9 def initialize @data = {} @mutex = Mutex.new end |
Instance Method Details
#[](name) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/ddtrace/contrib/registry.rb', line 26 def [](name) @mutex.synchronize do entry = @data[name] entry.klass if entry end end |
#add(name, klass, auto_patch = false) ⇒ Object
14 15 16 17 18 |
# File 'lib/ddtrace/contrib/registry.rb', line 14 def add(name, klass, auto_patch = false) @mutex.synchronize do @data[name] = Entry.new(name, klass, auto_patch).freeze end end |
#each ⇒ Object
20 21 22 23 24 |
# File 'lib/ddtrace/contrib/registry.rb', line 20 def each @mutex.synchronize do @data.each { |_, entry| yield(entry) } end end |
#to_h ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/ddtrace/contrib/registry.rb', line 33 def to_h @mutex.synchronize do @data.each_with_object({}) do |(_, entry), hash| hash[entry.name] = entry.auto_patch end end end |