Sha256: 54fa9f030178773b24045e88f64dd04d69e677915a4a1309867d44c6615f5bb7
Contents?: true
Size: 1.22 KB
Versions: 2
Compression:
Stored size: 1.22 KB
Contents
module PushToSNS class PushNotifier def initialize(params = {}) params.each do |attr, value| public_send("#{attr}=", value) end end def deliver devices.each do |device| SendPushNotification.new(device).perform(full_notification_for_device(device)) end end def devices raise "Please implement the method :devices to be able to load devices to notify." end def notification(device) raise "Please implement the method :notification with the message to send" end private def full_notification_for_device(device) defaults = { type: type, message: message } defaults.merge(notification(device)) end def type @type ||= self.class.type end def message @message ||= self.class.message end class << self attr_accessor :input_type, :input_message def type(input_type = nil) if input_type.nil? self.input_type else self.input_type = input_type end end def message(input_message = nil) if input_message.nil? self.input_message else self.input_message = input_message end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
push_to_sns-0.1.1 | lib/push_to_sns/push_notifier.rb |
push_to_sns-0.1.0 | lib/push_to_sns/push_notifier.rb |