Class: BMO::GCM::Notification::Payload
- Inherits:
-
Object
- Object
- BMO::GCM::Notification::Payload
- Defined in:
- lib/bmo/gcm/notification.rb
Overview
The Payload contains the data sent to Apple
Defined Under Namespace
Classes: PayloadTooLarge
Constant Summary collapse
- MAX_BYTE_SIZE =
4096
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
-
#initialize(data) ⇒ Payload
constructor
A new instance of Payload.
- #to_package ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(data) ⇒ Payload
Returns a new instance of Payload.
41 42 43 |
# File 'lib/bmo/gcm/notification.rb', line 41 def initialize(data) @data = Utils.coerce_to_symbols(data) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
39 40 41 |
# File 'lib/bmo/gcm/notification.rb', line 39 def data @data end |
Instance Method Details
#to_package ⇒ Object
45 46 47 |
# File 'lib/bmo/gcm/notification.rb', line 45 def to_package data end |
#validate! ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/bmo/gcm/notification.rb', line 49 def validate! if to_package.size > MAX_BYTE_SIZE str = <<-EOS Payload size should be less than #{Payload::MAX_BYTE_SIZE} bytes" EOS fail PayloadTooLarge, str end true end |