module MongoMapper::Plugins::Voteable::InstanceMethods
Public Instance Methods
add_vote!(vote_value, voter)
click to toggle source
# File lib/mongo_mapper/plugins/voteable.rb, line 20 def add_vote!(vote_value, voter) vote = self.votes.build(:value => vote_value, :voter => voter) return false unless vote.valid? vote.save self.class.push_uniq(self.id, 'voter_ids' => voter.id) self.increment('votes_count' => 1, 'votes_average' => vote_value.to_i) on_add_vote(vote) end
on_add_vote(vote)
click to toggle source
# File lib/mongo_mapper/plugins/voteable.rb, line 32 def on_add_vote(vote) raise NotImplementedError end
voteable?()
click to toggle source
# File lib/mongo_mapper/plugins/voteable.rb, line 18 def voteable?; true; end
voters()
click to toggle source
# File lib/mongo_mapper/plugins/voteable.rb, line 36 def voters User.find(self.voter_ids) end