Sha256: 04653cc04d9bebd5b64f286143120c6ff52124ca2df80e89a3cf4c27df7d6075

Contents?: true

Size: 646 Bytes

Versions: 7

Compression:

Stored size: 646 Bytes

Contents

# frozen_string_literal: true

module AbstractNotifier
  module AsyncAdapters
    class ActiveJob
      class DeliveryJob < ::ActiveJob::Base
        def perform(notifier_class, payload)
          AbstractNotifier::Notification.new(notifier_class.constantize, payload).notify_now
        end
      end

      DEFAULT_QUEUE = "notifiers"

      attr_reader :job

      def initialize(queue: DEFAULT_QUEUE, job: DeliveryJob)
        @job = job.set(queue: queue)
      end

      def enqueue(notifier_class, payload)
        job.perform_later(notifier_class.name, payload)
      end
    end
  end
end

AbstractNotifier.async_adapter ||= :active_job

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
active_delivery-1.0.0.rc2 lib/abstract_notifier/async_adapters/active_job.rb
abstract_notifier-0.3.2 lib/abstract_notifier/async_adapters/active_job.rb
abstract_notifier-0.3.1 lib/abstract_notifier/async_adapters/active_job.rb
abstract_notifier-0.3.0 lib/abstract_notifier/async_adapters/active_job.rb
abstract_notifier-0.2.0 lib/abstract_notifier/async_adapters/active_job.rb
abstract_notifier-0.1.1 lib/abstract_notifier/async_adapters/active_job.rb
abstract_notifier-0.1.0 lib/abstract_notifier/async_adapters/active_job.rb