Upgrading to use CouchRest 1.1.0.pre3 and new Hash-less design
This commit is contained in:
parent
6e025bb256
commit
7c7ee2c2b1
19 changed files with 197 additions and 137 deletions
|
@ -1,6 +1,6 @@
|
|||
module CouchRest
|
||||
module Model
|
||||
class Base < Document
|
||||
class Base < CouchRest::Document
|
||||
|
||||
extend ActiveModel::Naming
|
||||
|
||||
|
@ -51,14 +51,15 @@ module CouchRest
|
|||
#
|
||||
# If a block is provided the new model will be passed into the
|
||||
# block so that it can be populated.
|
||||
def initialize(doc = {}, options = {})
|
||||
doc = prepare_all_attributes(doc, options)
|
||||
# set the instances database, if provided
|
||||
def initialize(attributes = {}, options = {})
|
||||
super()
|
||||
prepare_all_attributes(attributes, options)
|
||||
# set the instance's 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
|
||||
|
||||
yield self if block_given?
|
||||
|
||||
after_initialize if respond_to?(:after_initialize)
|
||||
|
@ -79,16 +80,6 @@ module CouchRest
|
|||
super
|
||||
end
|
||||
|
||||
## Compatibility with ActiveSupport and older frameworks
|
||||
|
||||
# Hack so that CouchRest::Document, which descends from Hash,
|
||||
# doesn't appear to Rails routing as a Hash of options
|
||||
def is_a?(klass)
|
||||
return false if klass == Hash
|
||||
super
|
||||
end
|
||||
alias :kind_of? :is_a?
|
||||
|
||||
def persisted?
|
||||
!new?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue