Module: Mongoid::Reloading
- Included in:
- Components
- Defined in:
- lib/mongoid/reloading.rb
Overview
This module handles reloading behaviour of documents.
Instance Method Summary (collapse)
-
- (Document) reload
Reloads the Document attributes from the database.
Instance Method Details
- (Document) reload
Reloads the Document attributes from the database. If the document has not been saved then an error will get raised if the configuration option was set. This can reload root documents or embedded documents.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/mongoid/reloading.rb', line 18 def reload reloaded = _reload if Mongoid.raise_not_found_error && reloaded.empty? raise Errors::DocumentNotFound.new(self.class, id, id) end @attributes = reloaded changed_attributes.clear demongoized.clear apply_defaults reload_relations run_callbacks(:initialize) self end |