Class: NotificationObject
- Inherits:
-
Object
- Object
- NotificationObject
- Includes:
- ActiveModel::Conversion, ActiveModel::Naming, ActiveModel::Validations
- Defined in:
- lib/app/models/notification_object.rb
Instance Attribute Summary collapse
-
#additional_object ⇒ Object
Returns the value of attribute additional_object.
-
#alert ⇒ Object
Returns the value of attribute alert.
-
#badge ⇒ Object
Returns the value of attribute badge.
-
#sendable_object ⇒ Object
Returns the value of attribute sendable_object.
-
#sound ⇒ Object
Returns the value of attribute sound.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
- #build_object ⇒ Object
-
#initialize(attributes = {}) ⇒ NotificationObject
constructor
A new instance of NotificationObject.
- #persisted? ⇒ Boolean
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_object ⇒ Object
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 |
#alert ⇒ Object
Returns the value of attribute alert.
6 7 8 |
# File 'lib/app/models/notification_object.rb', line 6 def alert @alert end |
#badge ⇒ Object
Returns the value of attribute badge.
6 7 8 |
# File 'lib/app/models/notification_object.rb', line 6 def badge @badge end |
#sendable_object ⇒ Object
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 |
#sound ⇒ Object
Returns the value of attribute sound.
6 7 8 |
# File 'lib/app/models/notification_object.rb', line 6 def sound @sound end |
#token ⇒ Object
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_object ⇒ Object
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
34 35 36 |
# File 'lib/app/models/notification_object.rb', line 34 def persisted? false end |