Method: Syncano::Packets::Notification#initialize

Defined in:
lib/syncano/packets/notification.rb

#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