Method: CloudKit::Store#delete
- Defined in:
- lib/cloudkit/store.rb
#delete(uri, options = {}) ⇒ Object
Delete the resource specified by the URI. Requires the :etag option.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/cloudkit/store.rb', line 109 def delete(uri, ={}) methods = methods_for_uri(uri) return status_405(methods) unless methods.include?('DELETE') return invalid_entity_type unless @collections.include?(uri.collection_type) return etag_required unless [:etag] resource = CloudKit::Resource.first(.excluding(:etag).merge(:uri => uri.string)) return status_404 unless (resource && (resource.remote_user == [:remote_user])) return status_410 if resource.deleted? return status_412 if resource.etag != [:etag] resource.delete archived_resource = resource.previous_version return (archived_resource.uri.string, archived_resource.etag, resource.last_modified) end |