Added attributes= to casted model and extended doc

This commit is contained in:
Peter Gumeson 2009-05-27 13:24:25 -07:00
parent e48a6c8866
commit 704d0a09bd
4 changed files with 53 additions and 0 deletions

View file

@ -25,5 +25,17 @@ module CouchRest
def [] key
super(key.to_s)
end
# Sets the attributes from a hash
def update_attributes_without_saving(hash)
hash.each do |k, v|
raise NoMethodError, "#{k}= method not available, use property :#{k}" unless self.respond_to?("#{k}=")
end
hash.each do |k, v|
self.send("#{k}=",v)
end
end
alias :attributes= :update_attributes_without_saving
end
end