# File lib/couchrest/database.rb, line 262 def update_doc(doc_id, params = {}, update_limit=10) resp = {'ok' => false} new_doc = nil last_fail = nil until resp['ok'] or update_limit <= 0 doc = self.get(doc_id, params) # grab the doc new_doc = yield doc # give it to the caller to be updated begin resp = self.save_doc new_doc # try to PUT the updated doc into the db rescue RestClient::RequestFailed => e if e.http_code == 409 # Update collision update_limit -= 1 last_fail = e else # some other error raise e end end end raise last_fail unless resp['ok'] new_doc end