Class: Dtn::Streaming::MessagesRecorderObserver

Inherits:
Object
  • Object
show all
Defined in:
lib/dtn/streaming/messages_recorder_observer.rb

Overview

A sample class, which will record all messages, which were invoked by the client. It will spy and record all invocations for simpler further analyses

It’s costly for production use, but very convenient for dev & testing purposes to quickly understand what you will get from the API

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, **opts) ⇒ Object



17
18
19
# File 'lib/dtn/streaming/messages_recorder_observer.rb', line 17

def method_missing(method_name, **opts)
  invoked_methods[method_name] << opts[:message]
end

Instance Method Details

#invoked_methodsObject



13
14
15
# File 'lib/dtn/streaming/messages_recorder_observer.rb', line 13

def invoked_methods
  @invoked_methods ||= Hash.new { |h, k| h[k] = [] }
end

#respond_to_missing?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/dtn/streaming/messages_recorder_observer.rb', line 21

def respond_to_missing?(*)
  true
end