Class: LittleGhost::AgentBuilder::ActivityRelay

Inherits:
Object
  • Object
show all
Defined in:
lib/little_ghost/agent_builder.rb

Instance Method Summary collapse

Constructor Details

#initializeActivityRelay

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

#publishObject



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