class Pushing::NotificationDelivery
Public Instance Methods
deliver_later!(options = {})
click to toggle source
# File lib/pushing/notification_delivery.rb, line 31 def deliver_later!(options = {}) enqueue_delivery :deliver_now!, options end
deliver_now!()
click to toggle source
# File lib/pushing/notification_delivery.rb, line 35 def deliver_now! processed_notifier.handle_exceptions { do_deliver } end
message()
click to toggle source
# File lib/pushing/notification_delivery.rb, line 23 def message __getobj__ end
processed?()
click to toggle source
# File lib/pushing/notification_delivery.rb, line 27 def processed? @processed_notifier || @notification_message end
Private Instance Methods
do_deliver()
click to toggle source
# File lib/pushing/notification_delivery.rb, line 41 def do_deliver @notifier_class.inform_interceptors(self) responses = nil @notifier_class.deliver_notification(self) do responses = ::Pushing::Platforms.config.map do |platform, config| Adapters.instance(config).push!(message[platform]) if message[platform] end.compact end responses.each {|response| @notifier_class.inform_observers(self, response) } responses end
enqueue_delivery(delivery_method, options = {})
click to toggle source
# File lib/pushing/notification_delivery.rb, line 63 def enqueue_delivery(delivery_method, options = {}) if processed? ::Kernel.raise "You've accessed the message before asking to " \ "deliver it later, so you may have made local changes that would " \ "be silently lost if we enqueued a job to deliver it. Why? Only " \ "the notifier method *arguments* are passed with the delivery job! " \ "Do not access the message in any way if you mean to deliver it " \ "later. Workarounds: 1. don't touch the message before calling " \ "#deliver_later, 2. only touch the message *within your notifier " \ "method*, or 3. use a custom Active Job instead of #deliver_later." else args = @notifier_class.name, @action.to_s, delivery_method.to_s, *@args ::Pushing::DeliveryJob.set(options).perform_later(*args) end end
processed_notifier()
click to toggle source
# File lib/pushing/notification_delivery.rb, line 55 def processed_notifier @processed_notifier ||= begin notifier = @notifier_class.new notifier.process @action, *@args notifier end end