added an automated way to mark design docs as dirty after the db was reset

This commit is contained in:
Matt Aimonetti 2009-05-27 18:16:50 -07:00
parent e48a6c8866
commit c35c35157a
10 changed files with 41 additions and 25 deletions

View file

@ -236,6 +236,16 @@ module CouchRest
copy_doc(doc, dest)
end
def extended_document_classes
@extended_document_classes ||= []
end
# store extended document classes so we can clear
# their freshness when we reset the DB
def register_extended_document_class(klass)
extended_document_classes << klass
end
# Compact the database, removing old document revisions and optimizing space use.
def compact!
CouchRest.post "#{@uri}/_compact"
@ -271,11 +281,16 @@ module CouchRest
# DELETE the database itself. This is not undoable and could be rather
# catastrophic. Use with care!
def delete!
clear_extended_doc_fresh_cache
CouchRest.delete @uri
end
private
def clear_extended_doc_fresh_cache
extended_document_classes.each{|klass| klass.design_doc_fresh = false if klass.respond_to?(:design_doc_fresh=) }
end
def uri_for_attachment(doc, name)
if doc.is_a?(String)
puts "CouchRest::Database#fetch_attachment will eventually require a doc as the first argument, not a doc.id"