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={})
  publish   = options[:only].nil? || options[:only] == :publish
  subscribe = options[:only].nil? || options[:only] == :subscribe

  self.workers << Promiscuous::Publisher::Worker.new(options) if publish
  self.workers << Promiscuous::Subscriber::Worker.new(options) if subscribe
  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