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.
34 35 36 |
# File 'lib/mongo_mapper/plugins/document.rb', line 34 def _root_document self end |
#destroyed? ⇒ Boolean
15 16 17 |
# File 'lib/mongo_mapper/plugins/document.rb', line 15 def destroyed? @_destroyed == true end |
#reload ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mongo_mapper/plugins/document.rb', line 19 def reload if doc = self.class.query(:_id => id).query.first 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 |