Method: Wisper::Publisher#on

Defined in:
lib/wisper/publisher.rb

#on(*events, &block) ⇒ self

subscribe a block

Examples:

my_publisher.on(:order_created) { |args| ... }

Returns:

  • (self)

Raises:

  • (ArgumentError)
[View source] [View on GitHub]

25
26
27
28
29
30
# File 'lib/wisper/publisher.rb', line 25

def on(*events, &block)
  raise ArgumentError, 'must give at least one event' if events.empty?
  raise ArgumentError, 'must pass a block' if !block
  local_registrations << BlockRegistration.new(block, on: events)
  self
end