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.



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

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



24
25
26
27
28
29
30
# File 'lib/ruby_event_store/instrumented_dispatcher.rb', line 24

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



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

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

#respond_to_missing?(method_name, _include_private) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ruby_event_store/instrumented_dispatcher.rb', line 32

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