Class: PactBroker::Events::TemporaryListeners
- Inherits:
-
Wisper::TemporaryListeners
- Object
- Wisper::TemporaryListeners
- PactBroker::Events::TemporaryListeners
- Defined in:
- lib/pact_broker/events/subscriber.rb
Instance Method Summary collapse
Instance Method Details
#subscribe(*listeners) ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pact_broker/events/subscriber.rb', line 10 def subscribe(*listeners) = listeners.last.is_a?(Hash) ? listeners.pop : {} begin listeners.each { |listener| registrations << Wisper::ObjectRegistration.new(listener, ) } yield ensure unsubscribe(listeners) end self end |
#unsubscribe(listeners) ⇒ Object
21 22 23 24 25 |
# File 'lib/pact_broker/events/subscriber.rb', line 21 def unsubscribe(listeners) registrations.delete_if do |registration| listeners.include?(registration.listener) end end |