Class: PushToSNS::PushNotifier

Inherits:
Object
  • Object
show all
Defined in:
lib/push_to_sns/push_notifier.rb

Instance Method Summary collapse

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

#deliverObject



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.message}"
    end
  end
end

#devicesObject



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