Method: CouchClient::Document#delete!

Defined in:
lib/couch-client/document.rb

#delete!Object

Tries to delete a file from the server. If it us unable to, it will save the error and make it available via #error.



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/couch-client/document.rb', line 105

def delete!
  @code, body = @connection.hookup.delete([id], {"rev" => rev})
  
  # If the document was deleted
  if body["ok"]
    # Update the rev, set the deleted flag to `true` and return `true`
    self.rev = body["rev"]
    @deleted = true
    true
  else
    # Else save error message and return `false`.
    @error = {body["error"] => body["reason"]}
    false
  end
end