Skip to content

jonbell/mongo_watchable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MongoWatchable

A simple many-to-many assocation between watchers and watchables for mongodb.

Requirements

  • MongoDB
  • MongoMapper

Installation

sudo gem install mongo_watchable

Simple Example

class User
  include MongoMapper::Document
  include MongoWatchable::Watcher
end

class Widget
  include MongoMapper::Document
  include MongoWatchable::Watchable
end

To watch it:

user.watch(widget)

Check if user is watching a widget:

user.watching?(widget)

Return count of all widgets a user is watching:

user.widget_watchings.count

Return all widgets a user is watching:

user.widget_watchings

Return all users watching widget:

widget.user_watchers

Return count of all users watching widget:

widget.user_watchers.count

Unwatch a widget

user.unwatch(widget)

About

Added ability to watch documents

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages