Sha256: cc8c1b0e06acbb9de2756aa0a1a5d6e48a534dbefb0ae9eddadfe3c15cff2fae

Contents?: true

Size: 572 Bytes

Versions: 8

Compression:

Stored size: 572 Bytes

Contents

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
    ensure
      ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jackhammer-1.5.1 lib/jackhammer/message_receiver.rb
jackhammer-1.5.0 lib/jackhammer/message_receiver.rb
jackhammer-1.5.0.rc lib/jackhammer/message_receiver.rb
jackhammer-1.4.0 lib/jackhammer/message_receiver.rb
jackhammer-1.3.7 lib/jackhammer/message_receiver.rb
jackhammer-1.3.6 lib/jackhammer/message_receiver.rb
jackhammer-1.3.5 lib/jackhammer/message_receiver.rb
jackhammer-1.3.4 lib/jackhammer/message_receiver.rb