class Syncano::Packets::Notification

Class representing notification packets used in communication with the Sync Server

Attributes

channel[RW]
data[RW]
id[RW]
source[RW]
target[RW]
type[RW]

Public Class Methods

new(attributes) click to toggle source

Constructor for Syncano::Packets::Notification object @param [Hash] attributes

Calls superclass method Syncano::Packets::Base::new
# 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

Public Instance Methods

notification?() click to toggle source

Returns true if is a notification packet @return [TrueClass, FalseClass]

# File lib/syncano/packets/notification.rb, line 30
def notification?
  true
end