https://github.com/medihack/make_watchable
[Unmaintained] User-centric watching system for Rails 3 applications.
https://github.com/medihack/make_watchable
Last synced: 3 months ago
JSON representation
[Unmaintained] User-centric watching system for Rails 3 applications.
- Host: GitHub
- URL: https://github.com/medihack/make_watchable
- Owner: medihack
- License: mit
- Created: 2011-06-16T20:42:09.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2018-05-17T11:43:03.000Z (about 7 years ago)
- Last Synced: 2024-04-24T03:23:23.168Z (about 1 year ago)
- Language: Ruby
- Homepage:
- Size: 8.79 KB
- Stars: 31
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: MIT-LICENSE
Awesome Lists containing this project
README
= MakeWatchable
MakeWatchable is an extension for building a user-centric watching system for Rails 3 applications.
It currently supports ActiveRecord models.* This repository is unfortunately no longer maintained. If this library is still relevant and you want to maintain it, I am happy to hand this repository over.
== Installation
add MakeWatchable to your Gemfile
gem 'make_watchable'
afterwards execute
bundle install
generate the required migration file
rails generate make_watchable
migrate the database
rake db:migrate
== Usage
# Specify a model that can be watched.
class Repository < ActiveRecord::Base
make_watchable
end# Specify a model that can watch a watchable.
class User < ActiveRecord::Base
make_watcher
end# The user can now watch the watchable.
# If the user is already watching the watchable then an AlreadyWatchingError is raised.
user.watch!(repository)# The method without bang(!) does not raise the AlreadyWatchingError, but just return
# false when the watcher tries to watch an already watching watchable.
user.watch(repository)# The user may unwatch a watched watchable.
# If the watch was never watching the watchable then an NotWatchingError is raised.
user.unwatch!(repository)# The method without bang(!) does not raise the NotFlaggedError, but just returns false
# if the watcher is not watching the watchable.
user.unwatch(repository)# Get all watchings of a watchable.
repository.watchings# Get the watcher of the watching.
watching = repository.watchings.first
user = watching.watcher# Watchings can also be accessed by its watcher.
user.watchings# Check if the watcher watches a watchable
user.watches?(repository)# Check if a watchable is watched by a watcher
repository.watched_by?(user)== Testing
MakeWatchable uses RSpec for testing and has a rake task for executing the provided specs
rake spec
or simply
rake
Copyright © 2010-2011 Kai Schlamp (http://www.medihack.org), released under the MIT license