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(&block) ⇒ Object
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
10 11 12 13 |
# File 'lib/ddtrace/contrib/registry.rb', line 10 def initialize @data = {} @mutex = Mutex.new end |
Instance Method Details
#[](name) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/ddtrace/contrib/registry.rb', line 27 def [](name) @mutex.synchronize do entry = @data[name] entry.klass if entry end end |
#add(name, klass, auto_patch = false) ⇒ Object
15 16 17 18 19 |
# File 'lib/ddtrace/contrib/registry.rb', line 15 def add(name, klass, auto_patch = false) @mutex.synchronize do @data[name] = Entry.new(name, klass, auto_patch).freeze end end |
#each(&block) ⇒ Object
21 22 23 24 25 |
# File 'lib/ddtrace/contrib/registry.rb', line 21 def each(&block) @mutex.synchronize do @data.each_value(&block) end end |
#to_h ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/ddtrace/contrib/registry.rb', line 34 def to_h @mutex.synchronize do @data.each_with_object({}) do |(_, entry), hash| hash[entry.name] = entry.auto_patch end end end |