Class: Workers::DeferredDispatch

Inherits:
Base
  • Object
show all
Defined in:
app/workers/deferred_dispatch.rb

Instance Method Summary collapse

Methods inherited from Base

#suppress_annoying_errors

Instance Method Details

#perform(user_id, object_class_name, object_id, opts) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/workers/deferred_dispatch.rb', line 9

def perform(user_id, object_class_name, object_id, opts)
  user = User.find(user_id)
  object = object_class_name.constantize.find(object_id)
  opts = HashWithIndifferentAccess.new(opts)
  opts[:services] = user.services.where(:type => opts.delete(:service_types)).all

  if opts[:additional_subscribers].present?
    opts[:additional_subscribers] = Person.where(:id => opts[:additional_subscribers])
  end

  Postzord::Dispatcher.build(user, object, opts).post
end