Sha256: 19a5e7b83c1b5fb728dc0e1f532265fc65059c4d878797fec89230de36be8835

Contents?: true

Size: 509 Bytes

Versions: 5

Compression:

Stored size: 509 Bytes

Contents

# frozen_string_literal: true

module Jackhammer
  # An object meant to be instantiated once but used on each payload received
  # via the #call method
  class MessageReceiver
    attr_reader :handler_class

    def initialize(handler_class)
      @handler_class = handler_class
    end

    def call(message)
      handler = Object.const_get(handler_class)
      if handler.respond_to?(:perform_async)
        handler.perform_async message
      else
        handler.call message
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jackhammer-0.2.3 lib/jackhammer/message_receiver.rb
jackhammer-0.2.2 lib/jackhammer/message_receiver.rb
jackhammer-0.2.0 lib/jackhammer/message_receiver.rb
jackhammer-0.1.1 lib/jackhammer/message_receiver.rb
jackhammer-0.1.0 lib/jackhammer/message_receiver.rb