Module: Rpush::Client::ActiveModel::Gcm::Notification

Included in:
Rpush::Client::ActiveRecord::Gcm::Notification, Mongoid::Gcm::Notification, Redis::Gcm::Notification
Defined in:
lib/rpush/client/active_model/gcm/notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


6
7
8
9
10
11
12
13
14
15
# File 'lib/rpush/client/active_model/gcm/notification.rb', line 6

def self.included(base)
  base.instance_eval do
    validates :registration_ids, presence: true

    validates_with Rpush::Client::ActiveModel::PayloadDataSizeValidator, limit: 4096
    validates_with Rpush::Client::ActiveModel::RegistrationIdsCountValidator, limit: 1000

    validates_with Rpush::Client::ActiveModel::Gcm::ExpiryCollapseKeyMutualInclusionValidator
  end
end

Instance Method Details

#as_jsonObject


17
18
19
20
21
22
23
24
25
26
# File 'lib/rpush/client/active_model/gcm/notification.rb', line 17

def as_json
  json = {
    'registration_ids' => registration_ids,
    'delay_while_idle' => delay_while_idle,
    'data' => data
  }
  json['collapse_key'] = collapse_key if collapse_key
  json['time_to_live'] = expiry if expiry
  json
end