0.01
No commit activity in last 3 years
No release in over 3 years
A user-centric watching extension for Rails 3 applications.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0.0
= 0.8.7
~> 2.5.0
~> 1.3.0

Runtime

~> 3.0.0
 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 (www.medihack.org), released under the MIT license