Module: Rpush::Client::ActiveRecord::Apns::ActiveRecordSerializableNotification

Included in:
Rpush::Client::ActiveRecord::Apns2::Notification, Notification
Defined in:
lib/rpush/client/active_record/apns/active_record_serializable_notification.rb

Instance Method Summary collapse

Instance Method Details

#alertObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rpush/client/active_record/apns/active_record_serializable_notification.rb', line 16

def alert
  string_or_json = read_attribute(:alert)

  if has_attribute?(:alert_is_json)
    if alert_is_json?
      multi_json_load(string_or_json)
    else
      string_or_json
    end
  else
    begin
      multi_json_load(string_or_json)
    rescue StandardError
      string_or_json
    end
  end
end

#alert=(alert) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/rpush/client/active_record/apns/active_record_serializable_notification.rb', line 6

def alert=(alert)
  if alert.is_a?(Hash)
    write_attribute(:alert, multi_json_dump(alert))
    self.alert_is_json = true if has_attribute?(:alert_is_json)
  else
    write_attribute(:alert, alert)
    self.alert_is_json = false if has_attribute?(:alert_is_json)
  end
end

#soundObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/rpush/client/active_record/apns/active_record_serializable_notification.rb', line 44

def sound
  string_or_json = read_attribute(:sound)

  if has_attribute?(:sound_is_json)
    if sound_is_json?
      multi_json_load(string_or_json)
    else
      string_or_json
    end
  else
    begin
      multi_json_load(string_or_json)
    rescue StandardError
      string_or_json
    end
  end
end

#sound=(sound) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/rpush/client/active_record/apns/active_record_serializable_notification.rb', line 34

def sound=(sound)
  if sound.is_a?(Hash)
    write_attribute(:sound, multi_json_dump(sound))
    self.sound_is_json = true if has_attribute?(:sound_is_json)
  else
    write_attribute(:sound, sound)
    self.sound_is_json = false if has_attribute?(:sound_is_json)
  end
end