Class: NotificationObject

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Conversion, ActiveModel::Naming, ActiveModel::Validations
Defined in:
lib/app/models/notification_object.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ NotificationObject

Returns a new instance of NotificationObject.



12
13
14
15
16
# File 'lib/app/models/notification_object.rb', line 12

def initialize(attributes = {})
  attributes.each do |name, value|
    send("#{name}=", value)
  end
end

Instance Attribute Details

#additional_objectObject

Returns the value of attribute additional_object.



6
7
8
# File 'lib/app/models/notification_object.rb', line 6

def additional_object
  @additional_object
end

#alertObject

Returns the value of attribute alert.



6
7
8
# File 'lib/app/models/notification_object.rb', line 6

def alert
  @alert
end

#badgeObject

Returns the value of attribute badge.



6
7
8
# File 'lib/app/models/notification_object.rb', line 6

def badge
  @badge
end

#sendable_objectObject

Returns the value of attribute sendable_object.



6
7
8
# File 'lib/app/models/notification_object.rb', line 6

def sendable_object
  @sendable_object
end

#soundObject

Returns the value of attribute sound.



6
7
8
# File 'lib/app/models/notification_object.rb', line 6

def sound
  @sound
end

#tokenObject

Returns the value of attribute token.



6
7
8
# File 'lib/app/models/notification_object.rb', line 6

def token
  @token
end

Instance Method Details

#build_objectObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/app/models/notification_object.rb', line 18

def build_object
  notification_array = Array.new
  obj = Hash.new
  obj[:aps] = Hash.new
  obj[:aps][:alert] = self.alert
  obj[:aps][:badge]  = self.badge if self.badge
  obj[:aps][:sound] = self.sound if self.sound
  obj[self.additional_object.keys.first] = self.additional_object.values.first if self.additional_object

  notification_array[0] = self.token
  notification_array[1] = obj.symbolize_keys
  notification_array[2] = self.additional_object.symbolize_keys if self.additional_object

  self.sendable_object = notification_array
end

#persisted?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/app/models/notification_object.rb', line 34

def persisted?
  false
end