Class: AbstractNotifier::AsyncAdapters::ActiveJob

Inherits:
Object
  • Object
show all
Defined in:
lib/abstract_notifier/async_adapters/active_job.rb

Defined Under Namespace

Classes: DeliveryJob

Constant Summary collapse

DEFAULT_QUEUE =
"notifiers"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(queue: DEFAULT_QUEUE, job: DeliveryJob) ⇒ ActiveJob

Returns a new instance of ActiveJob.



16
17
18
19
# File 'lib/abstract_notifier/async_adapters/active_job.rb', line 16

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

Instance Attribute Details

#jobObject (readonly)

Returns the value of attribute job.



14
15
16
# File 'lib/abstract_notifier/async_adapters/active_job.rb', line 14

def job
  @job
end

#queueObject (readonly)

Returns the value of attribute queue.



14
15
16
# File 'lib/abstract_notifier/async_adapters/active_job.rb', line 14

def queue
  @queue
end

Instance Method Details

#enqueueObject



21
22
23
# File 'lib/abstract_notifier/async_adapters/active_job.rb', line 21

def enqueue(...)
  job.set(queue:).perform_later(...)
end

#enqueue_delivery(delivery) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/abstract_notifier/async_adapters/active_job.rb', line 25

def enqueue_delivery(delivery, **)
  job.set(queue:, **).perform_later(
    delivery.notifier_class.name,
    delivery.action_name,
    **delivery.delivery_params
  )
end