Module: Rpush::Client::ActiveModel::Adm::Notification

Included in:
Rpush::Client::ActiveRecord::Adm::Notification, Redis::Adm::Notification
Defined in:
lib/rpush/client/active_model/adm/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/adm/notification.rb', line 6

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

    validates_with Rpush::Client::ActiveModel::PayloadDataSizeValidator, limit: 6144
    validates_with Rpush::Client::ActiveModel::RegistrationIdsCountValidator, limit: 100

    validates_with Rpush::Client::ActiveModel::Adm::DataValidator
  end
end

Instance Method Details

#as_jsonObject



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

def as_json
  json = { 'data' => data }
  json['consolidationKey'] = collapse_key if collapse_key
  # number of seconds before message is expired
  json['expiresAfter'] = expiry if expiry
  json
end