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

@ -20,6 +20,15 @@ module CouchRest
subklass.properties = self.properties.dup
end
EOS
# re opening the use_database method so we can register our class
subklass.class_eval <<-EOS, __FILE__, __LINE__
def self.use_database(db)
super
db.register_extended_document_class(self) if db.respond_to?(:register_extended_document_class) && !db.extended_document_classes.include?(self)
end
EOS
end
# Accessors
@ -45,6 +54,8 @@ module CouchRest
end
end
# Automatically set <tt>updated_at</tt> and <tt>created_at</tt> fields
# on the document whenever saving occurs. CouchRest uses a pretty