Class: Notifiable::Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/notifiable/notification.rb

Instance Method Summary collapse

Instance Method Details

#add_device_token(d) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/notifiable/notification.rb', line 23

def add_device_token(d)
  provider = d.provider.to_sym

  unless notifiers[provider]
    clazz = Notifiable.notifier_class(self, d)
    raise "Notifier #{provider} not configured" unless clazz
    notifier = clazz.new(self)
    app.configure(provider, notifier)
    @notifiers[provider] = notifier
  end

  notifiers[provider].send_notification(d)
end

#batchObject



14
15
16
17
18
19
20
21
# File 'lib/notifiable/notification.rb', line 14

def batch
  yield(self)
  update(last_error_message: nil)
rescue Exception => e
  update(last_error_message: e.message)
ensure
  close
end

#send_paramsObject



37
38
39
# File 'lib/notifiable/notification.rb', line 37

def send_params
  @send_params ||= (parameters || {}).merge(n_id: id)
end