Module: AcidicJob::Extensions::Noticed
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/acidic_job/extensions/noticed.rb
Instance Method Summary collapse
-
#deliver_acidicly(recipients) ⇒ Object
THIS IS A HACK THAT COPIES AND PASTES KEY PARTS OF THE ‘Noticed::Base` CODE IN ORDER TO ALLOW US TO TRANSACTIONALLY DELIVER NOTIFICATIONS THIS IS THUS LIABLE TO BREAK WHENEVER THAT GEM IS UPDATED.
Instance Method Details
#deliver_acidicly(recipients) ⇒ Object
THIS IS A HACK THAT COPIES AND PASTES KEY PARTS OF THE ‘Noticed::Base` CODE IN ORDER TO ALLOW US TO TRANSACTIONALLY DELIVER NOTIFICATIONS THIS IS THUS LIABLE TO BREAK WHENEVER THAT GEM IS UPDATED
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/acidic_job/extensions/noticed.rb', line 17 def deliver_acidicly(recipients) delivery_methods = self.class.delivery_methods.dup Array.wrap(recipients).uniq.each do |recipient| if (index = delivery_methods.find_index { |m| m[:name] == :database }) database_delivery_method = delivery_methods.delete_at(index) self.record = run_delivery_method(database_delivery_method, recipient: recipient, enqueue: false, record: nil) end delivery_methods.map do |delivery_method| job_class = delivery_method_for(delivery_method[:name], delivery_method[:options]) args = { notification_class: self.class.name, options: delivery_method[:options], params: params, recipient: recipient, record: record } job = job_class.new(args) AcidicJob::Run.stage!(job) end end end |