Sha256: 90ac891b0da295a02b7dacb4bddfed3b0a5d77ca129d7a62fb3afb7a011ddb51

Contents?: true

Size: 601 Bytes

Versions: 1

Compression:

Stored size: 601 Bytes

Contents

# frozen_string_literal: true

module AbstractNotifier
  module AsyncAdapters
    class ActiveJob
      class DeliveryJob < ::ActiveJob::Base
        def perform(notifier_class, ...)
          AbstractNotifier::NotificationDelivery.new(notifier_class.constantize, ...).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(...)
        job.perform_later(...)
      end
    end
  end
end

AbstractNotifier.async_adapter ||= :active_job

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
active_delivery-1.0.0 lib/abstract_notifier/async_adapters/active_job.rb