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



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

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

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

#batchObject



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

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

#send_paramsObject



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

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