Class: Syncano::Packets::Notification
- Defined in:
- lib/syncano/packets/notification.rb
Overview
Class representing notification packets used in communication with the Sync Server
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#target ⇒ Object
readonly
Returns the value of attribute target.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Notification
constructor
Constructor for Syncano::Packets::Notification object.
-
#notification? ⇒ TrueClass, FalseClass
Returns true if is a notification packet.
Methods inherited from Base
#auth?, #call_response?, instantize_packet, #message?, #ping?
Constructor Details
#initialize(attributes) ⇒ Notification
Constructor for Syncano::Packets::Notification object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/syncano/packets/notification.rb', line 9 def initialize(attributes) super(attributes) self.id = attributes[:id] self.type = attributes[:type] self.channel = attributes[:channel] self.source = attributes[:source] self.target = attributes[:target] if type == 'change' self.data = { added: attributes[:add], updated: attributes[:replace], deleted: attributes[:delete] } else self.data = attributes[:data] end end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
5 6 7 |
# File 'lib/syncano/packets/notification.rb', line 5 def channel @channel end |
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/syncano/packets/notification.rb', line 5 def data @data end |
#id ⇒ Object
Returns the value of attribute id.
5 6 7 |
# File 'lib/syncano/packets/notification.rb', line 5 def id @id end |
#source ⇒ Object
Returns the value of attribute source.
5 6 7 |
# File 'lib/syncano/packets/notification.rb', line 5 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
5 6 7 |
# File 'lib/syncano/packets/notification.rb', line 5 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
5 6 7 |
# File 'lib/syncano/packets/notification.rb', line 5 def type @type end |
Instance Method Details
#notification? ⇒ TrueClass, FalseClass
Returns true if is a notification packet
30 31 32 |
# File 'lib/syncano/packets/notification.rb', line 30 def notification? true end |