Sha256: 935b3e37d1ea98a42abeb055298ac872fa6253504eceb3e512e6d35f0fc8d3cb

Contents?: true

Size: 765 Bytes

Versions: 2

Compression:

Stored size: 765 Bytes

Contents

module Mongoid
  module Voteable
    UP_VOTER_IDS      = 'votes.u'
    DOWN_VOTER_IDS    = 'votes.d'
    UP_VOTES_COUNT    = 'votes.uc'
    DOWN_VOTES_COUNT  = 'votes.dc'
    VOTES_COUNT       = 'votes.c'
    VOTES_POINT       = 'votes.p'
    
    class Votes
      include Mongoid::Document
      
      field :u, :type => Array, :default => []
      field :d, :type => Array, :default => []
      field :uc, :type => Integer, :default => 0
      field :dc, :type => Integer, :default => 0
      field :c, :type => Integer, :default => 0
      field :p, :type => Integer, :default => 0
      
      def identity
        # To remove _id
      end
    end
    
    VOTES_DEFAULT_ATTRIBUTES = Votes.new.attributes
    VOTES_DEFAULT_ATTRIBUTES.delete('_id')
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
voteable_mongoid-0.6.2 lib/voteable_mongoid/voteable/votes.rb
voteable_mongoid-0.6.1 lib/voteable_mongoid/voteable/votes.rb