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


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

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

#data=(attrs) ⇒ Object


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

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

#registration_ids=(ids) ⇒ Object


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

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