def delete_attachment(name)
assert_attachments_property
attachment = self.attachments[name] if self.attachments
unless attachment
return false
end
response = unless new_record?
adapter = repository.adapter
http = Net::HTTP.new(adapter.uri.host, adapter.uri.port)
uri = Addressable::URI.encode_component("#{attachment_path(name)}?rev=#{self.rev}")
http.delete(uri, 'Content-Type' => attachment['content_type'])
end
if response && !response.kind_of?(Net::HTTPSuccess)
false
else
self.attachments.delete(name)
self.attachments = nil if self.attachments.empty?
true
end
end