Module: Wisper::Publisher
- Included in:
- TestWisperPublisher
- Defined in:
- lib/wisper/publisher.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #add_block_listener(options = {}, &block) ⇒ Object
- #add_listener(listener, options = {}) ⇒ Object
- #listeners ⇒ Object
- #on(*events, &block) ⇒ Object
- #respond_to(*events, &block) ⇒ Object
- #subscribe(listener, options = {}) ⇒ Object
Instance Method Details
#add_block_listener(options = {}, &block) ⇒ Object
18 19 20 21 22 |
# File 'lib/wisper/publisher.rb', line 18 def add_block_listener( = {}, &block) warn "[DEPRECATED] use `on` instead of `add_block_listener`" local_registrations << BlockRegistration.new(block, ) self end |
#add_listener(listener, options = {}) ⇒ Object
24 25 26 27 |
# File 'lib/wisper/publisher.rb', line 24 def add_listener(listener, = {}) warn "[DEPRECATED] use `subscribe` instead of `add_listener`" subscribe(listener, ) end |
#listeners ⇒ Object
3 4 5 |
# File 'lib/wisper/publisher.rb', line 3 def listeners registrations.map(&:listener).freeze end |
#on(*events, &block) ⇒ Object
12 13 14 15 16 |
# File 'lib/wisper/publisher.rb', line 12 def on(*events, &block) raise ArgumentError, 'must give at least one event' if events.empty? local_registrations << BlockRegistration.new(block, on: events) self end |
#respond_to(*events, &block) ⇒ Object
29 30 31 32 |
# File 'lib/wisper/publisher.rb', line 29 def respond_to(*events, &block) warn '[DEPRECATED] use `on` instead of `respond_to`' on(*events, &block) end |
#subscribe(listener, options = {}) ⇒ Object
7 8 9 10 |
# File 'lib/wisper/publisher.rb', line 7 def subscribe(listener, = {}) local_registrations << ObjectRegistration.new(listener, ) self end |