Sha256: a68c120ad7d6245c0fa56c832d76d4f5d5bc188fd73fde90c6d3c635cc12200f

Contents?: true

Size: 615 Bytes

Versions: 4

Compression:

Stored size: 615 Bytes

Contents

require 'mongo_mapper'

module ActivityFeed
  module MongoMapper
    class Item
      include ::MongoMapper::Document    

      key :user_id, Integer, :required => true, :numeric => true
      key :nickname, String
      key :type, String
      key :title, String
      key :text, String
      key :url, String
      key :icon, String
      key :sticky, Boolean

      timestamps!

      self.ensure_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

4 entries across 4 versions & 1 rubygems

Version Path
activity_feed-1.4.0 lib/activity_feed/mongo_mapper/item.rb
activity_feed-1.3.0 lib/activity_feed/mongo_mapper/item.rb
activity_feed-1.2.1 lib/activity_feed/mongo_mapper/item.rb
activity_feed-1.2 lib/activity_feed/mongo_mapper/item.rb