Module: MongoMapper::Plugins::Document::InstanceMethods
- Defined in:
- lib/mongo_mapper/plugins/document.rb
Instance Method Summary collapse
-
#_root_document ⇒ Object
Used by embedded docs to find root easily without if/respond_to? stuff.
- #destroyed? ⇒ Boolean
- #new? ⇒ Boolean
- #reload ⇒ Object
Instance Method Details
#_root_document ⇒ Object
Used by embedded docs to find root easily without if/respond_to? stuff. Documents are always root documents.
35 36 37 |
# File 'lib/mongo_mapper/plugins/document.rb', line 35 def _root_document self end |
#destroyed? ⇒ Boolean
16 17 18 |
# File 'lib/mongo_mapper/plugins/document.rb', line 16 def destroyed? @_destroyed == true end |
#reload ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mongo_mapper/plugins/document.rb', line 20 def reload if doc = collection.find_one(:_id => id) tap do |instance| instance.class.associations.each_key do |association_name| send(association_name).reset if respond_to?(association_name) end instance.attributes = doc end else raise DocumentNotFound, "Document match #{_id.inspect} does not exist in #{collection.name} collection" end end |