Module: CouchRest::Model::ClassProxy::ClassMethods

Defined in:
lib/couchrest/model/class_proxy.rb

Instance Method Summary collapse

Instance Method Details

#on(database) ⇒ Object

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


28
29
30
# File 'lib/couchrest/model/class_proxy.rb', line 28

def on(database)
  Proxy.new(self, database)
end