module CouchRest::Mixins::ClassProxy::ClassMethods

Public Instance Methods

on(database) click to toggle source

Return a proxy object which represents a model class on a chosen database instance. This allows you to DRY operations where a database is chosen dynamically.

Example:

db = CouchRest::Database.new(...)
articles = Article.on(db)

articles.all { ... }
articles.by_title { ... }

u = articles.get("someid")

u = articles.new(:title => "I like plankton")
u.save    # saved on the correct database
# File lib/couchrest/mixins/class_proxy.rb, line 28
def on(database)
  Proxy.new(self, database)
end