Class: PushToSNS::PushNotifier
- Inherits:
-
Object
- Object
- PushToSNS::PushNotifier
- Defined in:
- lib/push_to_sns/push_notifier.rb
Instance Method Summary collapse
- #deliver ⇒ Object
- #devices ⇒ Object
-
#initialize(params = {}) ⇒ PushNotifier
constructor
A new instance of PushNotifier.
- #notification(device) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ PushNotifier
Returns a new instance of PushNotifier.
3 4 5 6 7 |
# File 'lib/push_to_sns/push_notifier.rb', line 3 def initialize(params = {}) params.each do |attr, value| public_send("#{attr}=", value) end end |
Instance Method Details
#deliver ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/push_to_sns/push_notifier.rb', line 9 def deliver devices.each do |device| begin SendPushNotification.new(device).perform(full_notification_for_device(device)) rescue AWS::SNS::Errors::Base => e $stderr.puts "Device can't send push notifications: #{e.}" end end end |
#devices ⇒ Object
19 20 21 |
# File 'lib/push_to_sns/push_notifier.rb', line 19 def devices raise "Please implement the method :devices to be able to load devices to notify." end |
#notification(device) ⇒ Object
23 24 25 |
# File 'lib/push_to_sns/push_notifier.rb', line 23 def notification(device) raise "Please implement the method :notification with the message to send" end |