Module: Rpush::Client::ActiveModel::Pushy::Notification

Included in:
Rpush::Client::ActiveRecord::Pushy::Notification, Redis::Pushy::Notification
Defined in:
lib/rpush/client/active_model/pushy/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
16
17
18
# File 'lib/rpush/client/active_model/pushy/notification.rb', line 6

def self.included(base)
  base.instance_eval do
    alias_attribute :time_to_live, :expiry

    validates :time_to_live, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
    validates :registration_ids, presence: true
    validates :data, presence: true

    validates_with Rpush::Client::ActiveModel::Pushy::TimeToLiveValidator
    validates_with Rpush::Client::ActiveModel::PayloadDataSizeValidator, limit: 4096
    validates_with Rpush::Client::ActiveModel::RegistrationIdsCountValidator, limit: 1000
  end
end

Instance Method Details

#as_json(_options = nil) ⇒ Object



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

def as_json(_options = nil)
  {
    'data'             => data,
    'time_to_live'     => time_to_live,
    'registration_ids' => registration_ids
  }
end