Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bookmark_system

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bookmark_system

  • 0.2.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

BookmarkSystem

Build Status Gem Version Code Climate

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? # returns true

post.bookmarked_by?(user) # returns true if user bookmarks the post object, false otherwise

post.bookmarkers_by(User) # returns a scope of BookmarkSystem::Bookmark join model that belongs to the post object and belongs to bookmarker objects of type User

Bookmarker object methods

user.is_bookmarker? # returns true

user.bookmark(post) # Creates an instance of BookmarkSystem::Bookmark join model associating the user object and the post object, returns true if succeded, false otherwise

user.unbookmark(post) # Destroys an instance of BookmarkSystem::Bookmark join model that associates the user object and the post object, returns true if succeded, false otherwise

user.toggle_bookmark(post) # Bookmarks / unbookmarks the post

user.bookmarks?(post) # returns true if the user object bookmarks the post object, false otherwise

user.bookmarkees_by(Post) # returns a scope of BookmarkSystem::Bookmark join model that belongs to the user object and belongs to bookmarkee objects of type Post

For more information read the api documentation.

Contributing

  1. Fork it ( https://github.com/pmviva/bookmark_system/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

FAQs

Package last updated on 05 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc