Class: BMO::GCM::Notification
- Inherits:
-
Object
- Object
- BMO::GCM::Notification
- Defined in:
- lib/bmo/gcm/notification.rb
Overview
The Notification Class handles all the packaging logic
Defined Under Namespace
Classes: Payload
Instance Attribute Summary collapse
-
#device_token ⇒ Object
readonly
Returns the value of attribute device_token.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
-
#initialize(device_token, payload) ⇒ Notification
constructor
A new instance of Notification.
- #to_package ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(device_token, payload) ⇒ Notification
Returns a new instance of Notification.
11 12 13 14 |
# File 'lib/bmo/gcm/notification.rb', line 11 def initialize(device_token, payload) @device_token = device_token @payload = Payload.new(payload) end |
Instance Attribute Details
#device_token ⇒ Object (readonly)
Returns the value of attribute device_token.
9 10 11 |
# File 'lib/bmo/gcm/notification.rb', line 9 def device_token @device_token end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
9 10 11 |
# File 'lib/bmo/gcm/notification.rb', line 9 def payload @payload end |
Instance Method Details
#to_package ⇒ Object
16 17 18 19 20 21 |
# File 'lib/bmo/gcm/notification.rb', line 16 def to_package { registration_ids: [device_token], data: payload.to_package }.to_json end |
#validate! ⇒ Object
23 24 25 |
# File 'lib/bmo/gcm/notification.rb', line 23 def validate! payload.validate! end |