class FFWD::Channel
Attributes
subs[R]
Public Class Methods
new(log, name)
click to toggle source
# File lib/ffwd/channel.rb, line 36 def initialize log, name @log = log @name = name @subs = Set.new end
Public Instance Methods
<<(item)
click to toggle source
# File lib/ffwd/channel.rb, line 42 def <<(item) @subs.each do |sub| begin sub.block.call item rescue => e @log.error "#{@name}: Subscription failed", e end end end
subscribe(&block)
click to toggle source
# File lib/ffwd/channel.rb, line 52 def subscribe(&block) s = Sub.new(self, block) @subs << s return s end
unsubscribe(sub)
click to toggle source
# File lib/ffwd/channel.rb, line 58 def unsubscribe sub @subs.delete sub end