Class: Punchblock::Client::ComponentRegistry
- Defined in:
- lib/punchblock/client/component_registry.rb
Instance Method Summary collapse
- #<<(component) ⇒ Object
- #delete(component) ⇒ Object
- #find_by_id(component_id) ⇒ Object
-
#initialize ⇒ ComponentRegistry
constructor
A new instance of ComponentRegistry.
Constructor Details
#initialize ⇒ ComponentRegistry
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.component_id] = 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 id = @components.key component @components.delete id end end |
#find_by_id(component_id) ⇒ Object
17 18 19 20 21 |
# File 'lib/punchblock/client/component_registry.rb', line 17 def find_by_id(component_id) @mutex.synchronize do @components[component_id] end end |