Class: Pushr::MessageGcm

Inherits:
Message
  • Object
show all
Defined in:
lib/pushr/message_gcm.rb

Constant Summary collapse

POSTFIX =
'gcm'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collapse_keyObject

Returns the value of attribute collapse_key.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def collapse_key
  @collapse_key
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def data
  @data
end

#delay_while_idleObject

Returns the value of attribute delay_while_idle.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def delay_while_idle
  @delay_while_idle
end

#dry_runObject

Returns the value of attribute dry_run.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def dry_run
  @dry_run
end

#notification_keyObject

Returns the value of attribute notification_key.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def notification_key
  @notification_key
end

#registration_idsObject

Returns the value of attribute registration_ids.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def registration_ids
  @registration_ids
end

#restricted_package_nameObject

Returns the value of attribute restricted_package_name.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def restricted_package_name
  @restricted_package_name
end

#time_to_liveObject

Returns the value of attribute time_to_live.



5
6
7
# File 'lib/pushr/message_gcm.rb', line 5

def time_to_live
  @time_to_live
end

Instance Method Details

#to_hashObject



23
24
25
26
27
28
# File 'lib/pushr/message_gcm.rb', line 23

def to_hash
  hsh = { type: self.class.to_s, app: app, registration_ids: registration_ids, notification_key: notification_key,
          collapse_key: collapse_key, delay_while_idle: delay_while_idle, time_to_live: time_to_live, data: data }
  hsh[Pushr::Core.external_id_tag] = external_id if external_id
  hsh
end

#to_messageObject



14
15
16
17
18
19
20
21
# File 'lib/pushr/message_gcm.rb', line 14

def to_message
  hsh = {}
  hsh['registration_ids'] = registration_ids
  %w(notification_key collapse_key delay_while_idle time_to_live data restricted_package_name dry_run).each do |variable|
    hsh[variable] = send(variable) if send(variable)
  end
  MultiJson.dump(hsh)
end