Class: Acta::Reactor

Inherits:
Handler show all
Defined in:
lib/acta/reactor.rb

Class Method Summary collapse

Methods inherited from Handler

on

Class Method Details

.queue_as(name) ⇒ Object

Declares the ActiveJob queue name to enqueue this reactor’s job on. Read by Acta’s dispatcher when the reactor is async (the default); ignored for ‘sync!` reactors. With no per-class declaration, the global `Acta.reactor_queue` setting applies; if that’s also unset, ActiveJob’s ‘:default` queue is used.

class WelcomeEmailReactor < Acta::Reactor
  queue_as :fast
  on UserSignedUp do |event|
    UserMailer.welcome(event.user_id).deliver_later
  end
end


26
27
28
# File 'lib/acta/reactor.rb', line 26

def queue_as(name)
  @queue_name = name
end

.queue_nameObject



30
31
32
33
34
# File 'lib/acta/reactor.rb', line 30

def queue_name
  return @queue_name if defined?(@queue_name)

  Acta.reactor_queue
end

.sync!Object



6
7
8
# File 'lib/acta/reactor.rb', line 6

def sync!
  @sync = true
end

.sync?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/acta/reactor.rb', line 10

def sync?
  @sync == true
end