class Emittance::Resque::EventFanoutJob

A job that fans out events to their proper listeners.

Constants

PROCESS_EVENT_JOB

Attributes

event[R]

Public Class Methods

new(event) click to toggle source
# File lib/emittance/resque/event_fanout_job.rb, line 21
def initialize(event)
  @event = event
end
perform(event) click to toggle source
# File lib/emittance/resque/event_fanout_job.rb, line 16
def perform(event)
  new(event).perform
end

Public Instance Methods

perform() click to toggle source
# File lib/emittance/resque/event_fanout_job.rb, line 25
def perform
  registrations.each { |registration| enqueue_job registration, event }
end

Private Instance Methods

default_queue() click to toggle source
# File lib/emittance/resque/event_fanout_job.rb, line 50
def default_queue
  Emittance::Resque::Dispatcher.default_queue
end
enqueue_job(registration, event) click to toggle source
# File lib/emittance/resque/event_fanout_job.rb, line 38
def enqueue_job(registration, event)
  queue = queue_from_registration(registration)

  ::Resque.enqueue_to(
    queue, PROCESS_EVENT_JOB, registration.klass_name, registration.method_name, event
  )
end
queue_from_registration(registration) click to toggle source
# File lib/emittance/resque/event_fanout_job.rb, line 46
def queue_from_registration(registration)
  registration.queue || default_queue
end
registrations() click to toggle source
# File lib/emittance/resque/event_fanout_job.rb, line 33
def registrations
  identifier = event['identifier']
  Emittance::Resque::Dispatcher.registrations_for(identifier)
end