Sha256: 0e464373954479cfbe032b511ce0dcaae39b5e74cd155b0a2af6c3cd78465b2a

Contents?: true

Size: 1.08 KB

Versions: 37

Compression:

Stored size: 1.08 KB

Contents

module Rpush
  module Client
    module ActiveRecord
      module Apns
        class Notification < Rpush::Client::ActiveRecord::Notification
          include Deprecatable
          include Rpush::Client::ActiveModel::Apns::Notification

          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

          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
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
rpush-4.1.1 lib/rpush/client/active_record/apns/notification.rb
rpush-4.1.0 lib/rpush/client/active_record/apns/notification.rb
rpush-4.0.1 lib/rpush/client/active_record/apns/notification.rb
rpush-4.0.0 lib/rpush/client/active_record/apns/notification.rb
rpush-3.3.1 lib/rpush/client/active_record/apns/notification.rb
rpush-3.3.0 lib/rpush/client/active_record/apns/notification.rb
rpush_extended-3.2.6 lib/rpush/client/active_record/apns/notification.rb
rpush_extended-3.2.5 lib/rpush/client/active_record/apns/notification.rb
rpush-3.2.4 lib/rpush/client/active_record/apns/notification.rb
rpush-3.2.3 lib/rpush/client/active_record/apns/notification.rb
rpush-3.2.2 lib/rpush/client/active_record/apns/notification.rb
rpush-3.2.1 lib/rpush/client/active_record/apns/notification.rb
rpush-3.2.0 lib/rpush/client/active_record/apns/notification.rb
rpush-3.1.1 lib/rpush/client/active_record/apns/notification.rb
rpush-3.1.0 lib/rpush/client/active_record/apns/notification.rb
rpush-3.0.2 lib/rpush/client/active_record/apns/notification.rb
rpush-3.0.1 lib/rpush/client/active_record/apns/notification.rb
rpush-3.0.0 lib/rpush/client/active_record/apns/notification.rb
rpush-3.0.0.rc1 lib/rpush/client/active_record/apns/notification.rb
rpush-2.7.0-java lib/rpush/client/active_record/apns/notification.rb