Sha256: 1765ecb51c3e31d6a3555d53983fd56f0b5de5ff6d43610023b525bd55077dce
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
module Smoke module Server class SignalRouter def initialize(*args) @processors = {} end def register(processor) signals = processor.process_signals if signals.blank? || signals.empty? connect(processor.to_s.sub(/Processor/, ''), processor) elsif signals.kind_of? Array signals.map { |signal| connect(signal, processor) } elsif signals.kind_of?(String) || signals.kind_of?(Symbol) connect(signals, processor) end end def connect(signal, processor) @processors[signal.to_s.classify] ||= [] @processors[signal.to_s.classify] << processor.new end def route(signal) # Sometimes we'll receive a signal that nothing has registered an # interested in so check that something is interested before passing # it along. if !@processors[signal["source"].to_s.classify].blank? @processors[signal["source"].to_s.classify].map do |processor| # Don't let the processors screw with the signal - duplicate it # before giving them access. processor.process(signal.dup) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
smoke-0.0.3 | lib/smoke/server/signal_router.rb |
smoke-0.0.1 | lib/smoke/server/signal_router.rb |