Class: Rapns::Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Rapns::Notification
show all
- Includes:
- MultiJsonHelper
- Defined in:
- lib/rapns/notification.rb
Instance Method Summary
collapse
#multi_json_dump, #multi_json_load
Constructor Details
Returns a new instance of Notification.
35
36
37
38
39
40
41
42
|
# File 'lib/rapns/notification.rb', line 35
def initialize(*args)
attributes = args.first
if attributes.is_a?(Hash) && attributes.keys.include?(:attributes_for_device)
msg = ":attributes_for_device via mass-assignment is deprecated. Use :data or the attributes_for_device= instance method."
Rapns::Deprecation.warn(msg)
end
super
end
|
Instance Method Details
#data ⇒ Object
50
51
52
|
# File 'lib/rapns/notification.rb', line 50
def data
multi_json_load(read_attribute(:data)) if read_attribute(:data)
end
|
#data=(attrs) ⇒ Object
44
45
46
47
48
|
# File 'lib/rapns/notification.rb', line 44
def data=(attrs)
return unless attrs
raise ArgumentError, "must be a Hash" if !attrs.is_a?(Hash)
write_attribute(:data, multi_json_dump(attrs))
end
|
#payload ⇒ Object
54
55
56
|
# File 'lib/rapns/notification.rb', line 54
def payload
multi_json_dump(as_json)
end
|
#payload_size ⇒ Object
58
59
60
|
# File 'lib/rapns/notification.rb', line 58
def payload_size
payload.bytesize
end
|