Added new_model? and new_record? alias to casted model for rails compatibility.

This commit is contained in:
Peter Gumeson 2009-05-28 16:09:53 -07:00
parent 9a026997dd
commit 23341f3698
4 changed files with 69 additions and 0 deletions

View file

@ -6,6 +6,7 @@ module CouchRest
def self.included(base)
base.send(:include, CouchRest::Mixins::Properties)
base.send(:attr_accessor, :casted_by)
base.send(:attr_accessor, :document_saved)
end
def initialize(keys={})
@ -26,6 +27,13 @@ module CouchRest
super(key.to_s)
end
# True if the casted model has already
# been saved in the containing document
def new_model?
!@document_saved
end
alias :new_record? :new_model?
# Sets the attributes from a hash
def update_attributes_without_saving(hash)
hash.each do |k, v|