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.
28
29
30
31
32
33
34
35
|
# File 'lib/rapns/notification.rb', line 28
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
43
44
45
|
# File 'lib/rapns/notification.rb', line 43
def data
multi_json_load(read_attribute(:data)) if read_attribute(:data)
end
|
#data=(attrs) ⇒ Object
37
38
39
40
41
|
# File 'lib/rapns/notification.rb', line 37
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
47
48
49
|
# File 'lib/rapns/notification.rb', line 47
def payload
multi_json_dump(as_json)
end
|
#payload_size ⇒ Object
51
52
53
|
# File 'lib/rapns/notification.rb', line 51
def payload_size
payload.bytesize
end
|