Class: Suj::Pusher::ApnNotification
- Inherits:
-
Object
- Object
- Suj::Pusher::ApnNotification
show all
- Includes:
- Logger
- Defined in:
- lib/suj/pusher/apn_notification.rb
Defined Under Namespace
Classes: InvalidToken, PayloadTooLarge
Constant Summary
collapse
- MAX_SIZE =
256
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ApnNotification.
10
11
12
13
14
15
16
17
|
# File 'lib/suj/pusher/apn_notification.rb', line 10
def initialize(options = {})
@token = options[:token]
@id = options[:id]
@ttl = options[:time_to_live] || 0
@options = options
raise InvalidToken if @token.nil? || (@token.length != 64)
raise PayloadTooLarge if data.size > MAX_SIZE
end
|
Instance Method Details
#data ⇒ Object
23
24
25
|
# File 'lib/suj/pusher/apn_notification.rb', line 23
def data
@data ||= encode_data
end
|
#payload ⇒ Object
19
20
21
|
# File 'lib/suj/pusher/apn_notification.rb', line 19
def payload
@payload ||= MultiJson.dump(@options[:data] || {})
end
|
#to_s ⇒ Object
27
28
29
|
# File 'lib/suj/pusher/apn_notification.rb', line 27
def to_s
data
end
|