class Jackhammer::MessageReceiver

An object meant to be instantiated once but used on each payload received via the call method

Attributes

handler_class[R]

Public Class Methods

new(handler_class) click to toggle source
# File lib/jackhammer/message_receiver.rb, line 7
def initialize(handler_class)
  @handler_class = handler_class
end

Public Instance Methods

call(message) click to toggle source
# File lib/jackhammer/message_receiver.rb, line 11
def call(message)
  handler = Object.const_get(handler_class)
  if handler.respond_to?(:perform_async)
    handler.perform_async message
  else
    handler.call message
  end
ensure
  ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
end