Sha256: 9a529e2dca44d68b13930a090be28c694a0b3ba143e8b5aeb36b680c27d24fee

Contents?: true

Size: 643 Bytes

Versions: 3

Compression:

Stored size: 643 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.namespace}:#{ActivityFeed.key}:#{self.user_id}", self.created_at.to_i, self.id)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activity_feed-1.1.1 lib/activity_feed/mongo_mapper/item.rb
activity_feed-1.1.0 lib/activity_feed/mongo_mapper/item.rb
activity_feed-1.0.0 lib/activity_feed/mongo_mapper/item.rb