Class: LittleGhost::AgentBuilder::ActivityRelay
- Inherits:
-
Object
- Object
- LittleGhost::AgentBuilder::ActivityRelay
- Defined in:
- lib/little_ghost/agent_builder.rb
Instance Method Summary collapse
-
#initialize ⇒ ActivityRelay
constructor
A new instance of ActivityRelay.
- #publish ⇒ Object
- #subscribe(&observer) ⇒ Object
Constructor Details
#initialize ⇒ ActivityRelay
Returns a new instance of ActivityRelay.
6 7 8 9 |
# File 'lib/little_ghost/agent_builder.rb', line 6 def initialize @mutex = Mutex.new @observers = [] end |
Instance Method Details
#publish ⇒ Object
15 16 17 |
# File 'lib/little_ghost/agent_builder.rb', line 15 def publish @mutex.synchronize { @observers.dup }.each(&:call) end |
#subscribe(&observer) ⇒ Object
11 12 13 |
# File 'lib/little_ghost/agent_builder.rb', line 11 def subscribe(&observer) @mutex.synchronize { @observers << observer } end |