Class: RubyEventStore::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/dispatcher.rb

Instance Method Summary collapse

Instance Method Details

#call(subscriber, event, _) ⇒ Object



5
6
7
8
# File 'lib/ruby_event_store/dispatcher.rb', line 5

def call(subscriber, event, _)
  subscriber = subscriber.new if Class === subscriber
  subscriber.call(event)
end

#verify(subscriber) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/ruby_event_store/dispatcher.rb', line 10

def verify(subscriber)
  begin
    subscriber_instance = Class === subscriber ? subscriber.new : subscriber
  rescue ArgumentError
    false
  else
    subscriber_instance.respond_to?(:call)
  end
end