Module: Promiscuous::Worker

Defined in:
lib/promiscuous/worker.rb

Class Method Summary collapse

Class Method Details

.replicate(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/promiscuous/worker.rb', line 5

def self.replicate(options={})
  options[:action] ||= [:publish, :subscribe]
  actions = [options[:action]].flatten

  self.workers << Promiscuous::Publisher::Worker.new(options)  if :publish.in? actions
  self.workers << Promiscuous::Subscriber::Worker.new(options) if :subscribe.in? actions
  self.workers.each { |w| w.replicate }
end

.stopObject



14
15
16
17
# File 'lib/promiscuous/worker.rb', line 14

def self.stop
  self.workers.each { |w| w.stop = true }
  self.workers.clear
end