Class: Rpush::Client::ActiveRecord::Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Rpush::Client::ActiveModel::Notification, MultiJsonHelper
Defined in:
lib/rpush/client/active_record/notification.rb

Instance Method Summary collapse

Methods included from Rpush::Client::ActiveModel::Notification

included, #payload, #payload_data_size

Methods included from MultiJsonHelper

#multi_json_dump, #multi_json_load

Instance Method Details

#dataObject



34
35
36
# File 'lib/rpush/client/active_record/notification.rb', line 34

def data
  multi_json_load(read_attribute(:data)) if read_attribute(:data)
end

#data=(attrs) ⇒ Object



17
18
19
20
21
# File 'lib/rpush/client/active_record/notification.rb', line 17

def data=(attrs)
  return unless attrs
  fail ArgumentError, 'must be a Hash' unless attrs.is_a?(Hash)
  write_attribute(:data, multi_json_dump(attrs.merge(data || {})))
end

#notificationObject



38
39
40
# File 'lib/rpush/client/active_record/notification.rb', line 38

def notification
  multi_json_load(read_attribute(:notification)) if read_attribute(:notification)
end

#notification=(attrs) ⇒ Object



23
24
25
26
27
# File 'lib/rpush/client/active_record/notification.rb', line 23

def notification=(attrs)
  return unless attrs
  fail ArgumentError, 'must be a Hash' unless attrs.is_a?(Hash)
  write_attribute(:notification, multi_json_dump(attrs.merge(notification || {})))
end

#registration_ids=(ids) ⇒ Object



29
30
31
32
# File 'lib/rpush/client/active_record/notification.rb', line 29

def registration_ids=(ids)
  ids = [ids] if ids && !ids.is_a?(Array)
  super
end