Sha256: 2e259865a9f9b2aa3bc54e1010ea24ea57b6b35d99bde783fd54d800e7c38d1d

Contents?: true

Size: 1.18 KB

Versions: 19

Compression:

Stored size: 1.18 KB

Contents

module Rpush
  module Client
    module ActiveRecord
      class Notification < ::ActiveRecord::Base
        include Rpush::MultiJsonHelper
        include Rpush::Client::ActiveModel::Notification

        self.table_name = 'rpush_notifications'

        serialize :registration_ids
        serialize :url_args

        belongs_to :app, class_name: 'Rpush::Client::ActiveRecord::App'

        def data=(attrs)
          return unless attrs
          fail ArgumentError, 'must be a Hash' unless attrs.is_a?(Hash)
          write_attribute(:data, multi_json_dump(attrs.merge(data || {})))
        end

        def notification=(attrs)
          return unless attrs
          fail ArgumentError, 'must be a Hash' unless attrs.is_a?(Hash)
          write_attribute(:notification, multi_json_dump(attrs.merge(data || {})))
        end

        def registration_ids=(ids)
          ids = [ids] if ids && !ids.is_a?(Array)
          super
        end

        def data
          multi_json_load(read_attribute(:data)) if read_attribute(:data)
        end

        def notification
          multi_json_load(read_attribute(:notification)) if read_attribute(:notification)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

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