Sha256: fece2b5e798b3fa9523ba44d5069d619fa0a016dbd78bdb99dad5915aeb450d1

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

require 'mongoid'

module ActivityFeed
  module Mongoid
    class Item
      include ::Mongoid::Document    
      include ::Mongoid::Timestamps

      field :user_id, type: Integer
      validates_presence_of :user_id

      field :nickname, type: String
      field :type, type: String
      field :title, type: String
      field :text, type: String
      field :url, type: String
      field :icon, type: String
      field :sticky, type: Boolean

      index :user_id

      after_save :update_redis

      private

      def update_redis
        ActivityFeed.redis.zadd(ActivityFeed.feed_key(self.user_id), self.created_at.to_i, self.id)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activity_feed-1.4.0 lib/activity_feed/mongoid/item.rb