Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Add like/dislike feature to Mongoid and Mongo_Mapper
Ruby
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
README.rdoc
Rakefile
mongo_likeable.gemspec

README.rdoc

mongo_likeable

Works for both Mongoid and Mongo_Mapper!

Installation

In console:

gem install mongo_likeable

or in Gemfile:

gem 'mongo_likeable'

Usage

To make model likeable you need to include Mongo::Likeable into your document:

class User
  include Mongoid::Document  #for Mongo_Mapper users, this line of code should be include MongoMapper::Document
  include Mongo::Likeable
end

After this,

u = User.new
u.like?(some_stuff)

u.like(some_stuff) # make sure you do this check before like/dislike
                   # cuz like and dislike the same thing at the same time seems strange
u.like(*some_array_of_stuffs) # like an array of stuffs

u.dislike(some_other_stuff)

u.clear_likes() # if no parameter is given, all likes will be cleared.
u.clear_likes(s, s1, s2...)

u.like_counts # display total counts
u.dislike_counts

u.all_likers # display all objects who like/dislike u
u.all_dislikers

u.like_history # display like/dislike histories of u
u.dislike_history
  • Any bug or issue, please send me an email: ustc.flyingfox@gmail.com

TODO

  • like/dislike history.(DONE)

Copyright

Copyright © Jie Fan. See LICENSE.txt for further details.

Something went wrong with that request. Please try again.