Class: Punchblock::Client::ComponentRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/punchblock/client/component_registry.rb

Instance Method Summary collapse

Constructor Details

#initializeComponentRegistry

Returns a new instance of ComponentRegistry


6
7
8
9
# File 'lib/punchblock/client/component_registry.rb', line 6

def initialize
  @mutex = Mutex.new
  @components = Hash.new
end

Instance Method Details

#<<(component) ⇒ Object


11
12
13
14
15
# File 'lib/punchblock/client/component_registry.rb', line 11

def <<(component)
  @mutex.synchronize do
    @components[component.source_uri] = component
  end
end

#delete(component) ⇒ Object


23
24
25
26
27
28
# File 'lib/punchblock/client/component_registry.rb', line 23

def delete(component)
  @mutex.synchronize do
    uri = @components.key component
    @components.delete uri
  end
end

#find_by_uri(uri) ⇒ Object


17
18
19
20
21
# File 'lib/punchblock/client/component_registry.rb', line 17

def find_by_uri(uri)
  @mutex.synchronize do
    @components[uri]
  end
end