Class: RubyEventStore::InstrumentedDispatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(dispatcher, instrumentation) ⇒ InstrumentedDispatcher

Returns a new instance of InstrumentedDispatcher.



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

def initialize(dispatcher, instrumentation)
  @dispatcher = dispatcher
  @instrumentation = instrumentation
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *arguments, **keyword_arguments, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/ruby_event_store/instrumented_dispatcher.rb', line 16

def method_missing(method_name, *arguments, **keyword_arguments, &block)
  if respond_to?(method_name)
    dispatcher.public_send(method_name, *arguments, **keyword_arguments, &block)
  else
    super
  end
end

Instance Method Details

#call(subscriber, event, record) ⇒ Object



10
11
12
13
14
# File 'lib/ruby_event_store/instrumented_dispatcher.rb', line 10

def call(subscriber, event, record)
  instrumentation.instrument("call.dispatcher.rails_event_store", event: event, subscriber: subscriber) do
    dispatcher.call(subscriber, event, record)
  end
end

#respond_to_missing?(method_name, _include_private) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/ruby_event_store/instrumented_dispatcher.rb', line 24

def respond_to_missing?(method_name, _include_private)
  dispatcher.respond_to?(method_name)
end