Class: Syncano::Packets::Notification

Inherits:
Base
  • Object
show all
Defined in:
lib/syncano/packets/notification.rb

Overview

Class representing notification packets used in communication with the Sync Server

Instance Attribute Summary collapse

Attributes inherited from Base

#object, #timestamp

Instance Method Summary collapse

Methods inherited from Base

#auth?, #call_response?, instantize_packet, #message?, #ping?

Constructor Details

#initialize(attributes) ⇒ Notification

Constructor for Syncano::Packets::Notification object

Parameters:

  • attributes (Hash)


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

#channelObject

Returns the value of attribute channel.



5
6
7
# File 'lib/syncano/packets/notification.rb', line 5

def channel
  @channel
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/syncano/packets/notification.rb', line 5

def data
  @data
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/syncano/packets/notification.rb', line 5

def id
  @id
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/syncano/packets/notification.rb', line 5

def source
  @source
end

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/syncano/packets/notification.rb', line 5

def target
  @target
end

#typeObject

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

Returns:

  • (TrueClass, FalseClass)


30
31
32
# File 'lib/syncano/packets/notification.rb', line 30

def notification?
  true
end