ClassProxy provides class-level methods on a dynamically chosen database.

Examples:

  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
This commit is contained in:
Brian Candler 2009-03-27 13:42:49 +00:00
parent af6ac7df89
commit c4b49baecf
4 changed files with 180 additions and 1 deletions

View file

@ -11,6 +11,7 @@ module CouchRest
include CouchRest::Mixins::Views
include CouchRest::Mixins::DesignDoc
include CouchRest::Mixins::ExtendedAttachments
include CouchRest::Mixins::ClassProxy
def self.inherited(subklass)
subklass.send(:include, CouchRest::Mixins::Properties)