Git Product home page Git Product logo

mongoid-likeable's Introduction

mongoid-likeable

Build Status Gem Version Dependency Status Code Climate Coverage Status

Add like to your Mongoid documents. This is a fork of tombell/mongoid-voteable for people who only need likes.

Installation

Install the gem

$ gem install mongoid-likeable

or add the gem to your Gemfile

gem 'mongoid-likeable'

Thread safety

This gem is thread safe.

Usage

Include the Mongoid::Likeable module into your models you want to like.

class Story
  include Mongoid::Document
  include Mongoid::Likeable

  # ...
end

You can then like by simply using the like method on the model.

@story.like @user   # @user likes @story
@story.unlike @user # @user doesn't like @story anymore

You also have access to a helpful method.

@story.liked? @user # true if @user likes @story

Like count is stored in a field called likes, so you can sort models by that field.

You can also get the all the users that liked this object.

@story.likers   # returns a list of users that liked @story

Note if your users are not stored in a Mongo collection or the ID field is not called _id you can still pass the ID in as the second parameter instead.

@story.like @user.id

@story.liked? @user.id

Contributing

Please read through our contributing guidelines. Included are directions for opening issues, coding standards, and notes on development.

More over, if your pull request contains patches or features, you must include relevant unit tests.

Editor preferences are available in the editor config for easy use in common text editors. Read more and download plugins at http://editorconfig.org.

Versioning

For transparency and insight into our release cycle, and for striving to maintain backward compatibility, mongoid-likeable will be maintained under the Semantic Versioning guidelines as much as possible. mongoid-likeable will not follow mongoid's version number.

Releases will be numbered with the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major (and resets the minor and patch)
  • New additions without breaking backward compatibility bumps the minor (and resets the patch)
  • Bug fixes and misc changes bumps the patch

For more information on SemVer, please visit http://semver.org/.

Authors

Geremia Taglialatela

Cesidio Di Landa

Copyright and license

Copyright 2014 diowa under the BSD 2-Clause license.

mongoid-voteable is licensed under the MIT License - Copyright (c) 2012 Tom Bell

mongoid-likeable's People

Contributors

tagliala avatar cesidio avatar tombell avatar brucexlin avatar chamnap avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.