BookmarkSystem
![Code Climate](https://codeclimate.com/github/pmviva/bookmark_system/badges/gpa.svg)
An active record bookmark system developed using ruby on rails applying domain driven design and test driven development principles.
For rails 4 support use branch v0.0.7-stable.
For rails 5 support use branch v0.1.1-stable.
This gem is heavily influenced by cmer/socialization.
Installation
Add this line to your application's Gemfile:
gem 'bookmark_system'
And then execute:
$ bundle
Or install it yourself as:
$ gem install bookmark_system
Usage
Run the generator
$ rails g bookmark_system
Let's suppose for a moment that you have a blog application and a User can bookmark a Post or several Post models.
The user model becomes the bookmarker and the post model becomes the bookmarkee.
Post object
class Post < ActiveRecord::Base
act_as_bookmarkee
validates :content, presence: true
end
User object
class User < ActiveRecord::Base
act_as_bookmarker
validates :username, { presence: true, uniqueness: true }
end
Bookmarkee object methods
post.is_bookmarkee?
post.bookmarked_by?(user)
post.bookmarkers_by(User)
Bookmarker object methods
user.is_bookmarker?
user.bookmark(post)
user.unbookmark(post)
user.toggle_bookmark(post)
user.bookmarks?(post)
user.bookmarkees_by(Post)
For more information read the api documentation.
Contributing
- Fork it ( https://github.com/pmviva/bookmark_system/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request