Class: Rpush::Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Rpush::Notification
show all
- Includes:
- MultiJsonHelper
- Defined in:
- lib/rpush/notification.rb
Class Method Summary
collapse
Instance Method Summary
collapse
#multi_json_dump, #multi_json_load
Class Method Details
.completed_and_older_than(dt) ⇒ Object
64
65
66
|
# File 'lib/rpush/notification.rb', line 64
def completed_and_older_than(dt)
completed.created_before(dt)
end
|
.created_before(dt) ⇒ Object
60
61
62
|
# File 'lib/rpush/notification.rb', line 60
def created_before(dt)
where("created_at < ?", dt)
end
|
Instance Method Details
#data ⇒ Object
43
44
45
|
# File 'lib/rpush/notification.rb', line 43
def data
multi_json_load(read_attribute(:data)) if read_attribute(:data)
end
|
#data=(attrs) ⇒ Object
32
33
34
35
36
|
# File 'lib/rpush/notification.rb', line 32
def data=(attrs)
return unless attrs
raise ArgumentError, "must be a Hash" if !attrs.is_a?(Hash)
write_attribute(:data, multi_json_dump(attrs.merge(data || {})))
end
|
#payload ⇒ Object
47
48
49
|
# File 'lib/rpush/notification.rb', line 47
def payload
multi_json_dump(as_json)
end
|
#payload_data_size ⇒ Object
55
56
57
|
# File 'lib/rpush/notification.rb', line 55
def payload_data_size
multi_json_dump(as_json['data']).bytesize
end
|
#payload_size ⇒ Object
51
52
53
|
# File 'lib/rpush/notification.rb', line 51
def payload_size
payload.bytesize
end
|
#registration_ids=(ids) ⇒ Object
38
39
40
41
|
# File 'lib/rpush/notification.rb', line 38
def registration_ids=(ids)
ids = [ids] if ids && !ids.is_a?(Array)
super
end
|