Module: MongoMapper::Plugins::Document
- Extended by:
- ActiveSupport::Concern
- Included in:
- Document
- Defined in:
- lib/mongo_mapper/plugins/document.rb
Defined Under Namespace
Modules: ClassMethods
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.
36 37 38 |
# File 'lib/mongo_mapper/plugins/document.rb', line 36 def _root_document self end |
#destroyed? ⇒ Boolean
17 18 19 |
# File 'lib/mongo_mapper/plugins/document.rb', line 17 def destroyed? @_destroyed == true end |
#reload ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/mongo_mapper/plugins/document.rb', line 21 def reload if doc = collection.find_one(:_id => id) self.class.associations.each_value do |association| get_proxy(association).reset end instance_variables.each { |ivar| instance_variable_set(ivar, nil) } load_from_database(doc) self else raise DocumentNotFound, "Document match #{_id.inspect} does not exist in #{collection.name} collection" end end |