lib/couchrest/model/base.rb in couchrest_model-1.0.0 vs lib/couchrest/model/base.rb in couchrest_model-1.1.0.beta
- old
+ new
@@ -10,14 +10,16 @@
include CouchRest::Model::DocumentQueries
include CouchRest::Model::Views
include CouchRest::Model::DesignDoc
include CouchRest::Model::ExtendedAttachments
include CouchRest::Model::ClassProxy
+ include CouchRest::Model::Proxyable
include CouchRest::Model::Collection
include CouchRest::Model::PropertyProtection
include CouchRest::Model::Associations
include CouchRest::Model::Validations
+ include CouchRest::Model::Designs
def self.subclasses
@subclasses ||= []
end
@@ -43,12 +45,15 @@
# using the provided document hash.
#
# Options supported:
#
# * :directly_set_attributes: true when data comes directly from database
+ # * :database: provide an alternative database
#
def initialize(doc = {}, options = {})
doc = prepare_all_attributes(doc, options)
+ # set the instances database, if provided
+ self.database = options[:database] unless options[:database].nil?
super(doc)
unless self['_id'] && self['_rev']
self[self.model_type_key] = self.class.to_s
end
after_initialize if respond_to?(:after_initialize)