module MongoMapper::Plugins::Document
Public Instance Methods
_root_document()
click to toggle source
Used by embedded docs to find root easily without if/respond_to? stuff. Documents are always root documents.
# File lib/mongo_mapper/plugins/document.rb, line 36 def _root_document self end
destroyed?()
click to toggle source
# File lib/mongo_mapper/plugins/document.rb, line 17 def destroyed? !!(@_destroyed ||= false) end
new?()
click to toggle source
# File lib/mongo_mapper/plugins/document.rb, line 13 def new? !!(@_new ||= false) end
reload()
click to toggle source
# File lib/mongo_mapper/plugins/document.rb, line 21 def reload if doc = collection.find({:_id => id},{limit: -1}).first self.class.associations.each_value do |association| get_proxy(association).reset end instance_variables.each { |ivar| remove_instance_variable(ivar) } initialize_from_database(doc) self else raise DocumentNotFound, "Document match #{_id.inspect} does not exist in #{collection.name} collection" end end