Class: Wisper::Bubbleable::Pipeline
- Inherits:
-
Object
- Object
- Wisper::Bubbleable::Pipeline
- Defined in:
- lib/wisper/bubbleable/pipeline.rb
Instance Method Summary collapse
-
#initialize(from, *events) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #to(target) ⇒ Object
Constructor Details
#initialize(from, *events) ⇒ Pipeline
Returns a new instance of Pipeline.
6 7 8 9 |
# File 'lib/wisper/bubbleable/pipeline.rb', line 6 def initialize(from, *events) @from = from @events = events end |
Instance Method Details
#to(target) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/wisper/bubbleable/pipeline.rb', line 11 def to(target) @events.each do |ev| @from.on(ev) do |*args| # listeners = target.send(:local_registrations).map(&:listener) # listeners += target.send(:temporary_registrations).map(&:listener) # should_broadcast = target.listeners.any? { |listener| listener.respond_to?(ev) } # target.send(:broadcast, ev, *args) if should_broadcast target.send(:broadcast, ev, *args) end end end |