Class: Notifiable::NotifierBase

Inherits:
Object
  • Object
show all
Defined in:
lib/notifiable/notifier_base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(env, notification) ⇒ NotifierBase

Returns a new instance of NotifierBase.



7
8
9
10
11
# File 'lib/notifiable/notifier_base.rb', line 7

def initialize(env, notification)
  @env, @notification = env, notification
  @localized_notifications = {}
  notification.localized_notifications.each{|l| @localized_notifications[l.locale] = l}
end

Instance Attribute Details

#envObject (readonly)

Returns the value of attribute env.



5
6
7
# File 'lib/notifiable/notifier_base.rb', line 5

def env
  @env
end

#localized_notificationsObject (readonly)

Returns the value of attribute localized_notifications.



5
6
7
# File 'lib/notifiable/notifier_base.rb', line 5

def localized_notifications
  @localized_notifications
end

#notificationObject (readonly)

Returns the value of attribute notification.



5
6
7
# File 'lib/notifiable/notifier_base.rb', line 5

def notification
  @notification
end

Instance Method Details

#closeObject



18
19
20
21
22
# File 'lib/notifiable/notifier_base.rb', line 18

def close
  flush
  save_receipts if Notifiable.save_receipts
  @notification.save
end

#send_notification(device_token) ⇒ Object



13
14
15
16
# File 'lib/notifiable/notifier_base.rb', line 13

def send_notification(device_token)
  localized_notification = self.localized_notification(device_token)
  enqueue(device_token, localized_notification) if localized_notification
end