Class: Push0r::PushMessage Abstract
- Inherits:
-
Object
- Object
- Push0r::PushMessage
- Defined in:
- lib/push0r/PushMessage.rb
Overview
This class is abstract.
PushMessage is the base class for all implemented push message types. A PushMessage encapsulates values like the notification’s payload, its receiver, etc.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#identifier ⇒ Fixnum
readonly
the unique identifier for this push message.
-
#payload ⇒ Hash
readonly
the payload for this push message.
-
#receiver_token ⇒ String, Array
readonly
the receiver’s push token.
-
#time_to_live ⇒ Fixnum
readonly
the time to live in seconds for this push message.
Instance Method Summary collapse
-
#attach(payload = {}) ⇒ self
Attaches the given payload to the push message.
-
#initialize(receiver_token, identifier = nil, time_to_live = nil) ⇒ PushMessage
constructor
Creates a new PushMessage instance.
Constructor Details
#initialize(receiver_token, identifier = nil, time_to_live = nil) ⇒ PushMessage
Creates a new PushMessage instance
15 16 17 18 19 20 |
# File 'lib/push0r/PushMessage.rb', line 15 def initialize(receiver_token, identifier = nil, time_to_live = nil) @receiver_token = receiver_token @identifier = identifier @time_to_live = time_to_live @payload = {} end |
Instance Attribute Details
#identifier ⇒ Fixnum (readonly)
the unique identifier for this push message
8 9 10 |
# File 'lib/push0r/PushMessage.rb', line 8 def identifier @identifier end |
#payload ⇒ Hash (readonly)
the payload for this push message
8 9 10 |
# File 'lib/push0r/PushMessage.rb', line 8 def payload @payload end |
#receiver_token ⇒ String, Array (readonly)
the receiver’s push token
8 9 10 |
# File 'lib/push0r/PushMessage.rb', line 8 def receiver_token @receiver_token end |
#time_to_live ⇒ Fixnum (readonly)
the time to live in seconds for this push message
8 9 10 |
# File 'lib/push0r/PushMessage.rb', line 8 def time_to_live @time_to_live end |
Instance Method Details
#attach(payload = {}) ⇒ self
Note:
attaching is done using the merge! method of the Hash class, i.e. be careful not to overwrite previously set Hash keys.
Attaches the given payload to the push message.
26 27 28 29 |
# File 'lib/push0r/PushMessage.rb', line 26 def attach(payload = {}) @payload.merge!(payload) return self end |