Module: PhobosDBCheckpoint::EventHelper

Included in:
Event, Failure
Defined in:
lib/phobos_db_checkpoint/event_helper.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/phobos_db_checkpoint/event_helper.rb', line 20

def method_missing(m, *args, &block)
  rex = m.to_s.match /^fetch_(.+)/

  if rex
    handler = configured_handler.new
    return handler.send(rex[1], payload) if handler.respond_to?(rex[1])
  else
    super
  end
end

Instance Method Details

#configured_handlerObject



14
15
16
17
18
# File 'lib/phobos_db_checkpoint/event_helper.rb', line 14

def configured_handler
  configured_listener
    .handler
    .constantize
end

#configured_listenerObject



3
4
5
6
7
8
9
10
11
12
# File 'lib/phobos_db_checkpoint/event_helper.rb', line 3

def configured_listener
  listener = Phobos
    .config
    .listeners
    .find { |l| l.group_id == self.group_id }

  raise(ListenerNotFoundError, self.group_id) unless listener

  listener
end