Added helper for accessing the top level document. And more rails compatibility.

This commit is contained in:
Peter Gumeson 2009-05-28 22:42:30 -07:00
parent 936ce54449
commit d012380b67
5 changed files with 80 additions and 0 deletions

View file

@ -27,6 +27,13 @@ module CouchRest
super(key.to_s)
end
# Gets a reference to the top level extended
# document that a model is saved inside of
def base_doc
raise "Cannot call base_doc on a model that is not yet casted by a document" unless @casted_by
@casted_by.base_doc
end
# False if the casted model has already
# been saved in the containing document
def new_model?