Mm-voteable is a project mainly written in Ruby, based on the MIT license.
A very simple mongomapper plugin to add vote up/down functionality to your application
= mm-voteable
A very simple mongomapper plugin to add vote up/down superpowers to your models.
v1.2 is a mongomapper 0.9.0 update to support the new plugin system if you are using mongomapper 0.8.x please use version 1.1 of the gem
== Usage
Install the gem
gem install mm-voteable
Or add it to your Gemfile
gem 'mm-voteable'
Then add the voteable plugin to you MongoMapper::Document
class Post
include MongoMapper::Document
plugin MongoMapper::Plugins::Voteable
def on_add_vote(vote)
do something when a vote is added...
end
end
You must implement the on_add_vote callback! - It can be an empty implementation, but I use it to create ActivityStream Items after someone votes on a NewsArticle
@post = Post.create
@voter = User.create
@post.add_vote!(1, @user)
@post.add_vote!(1, @user)
@post.votes_count #=> 2
@posts.votes #=> [<Vote>]
@posts.voters #=> [<User>]
@posts.voters.include?(@voter) #=> true
== Limitations
I made this plugin for voting up and down on articles (kind of like stack overflow) so there are currently some limitations
Feel free to code any of these limitations out and send me a patch, this is just how I have used it so far
== Contributing to mm-voteable
== Copyright
Copyright (c) 2010 Luke Cunningham. See LICENSE.txt for further details.