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.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