Module: Mongoid::Reloadable

Included in:
Composable
Defined in:
lib/mongoid/reloadable.rb

Overview

This module handles reloading behavior of documents.

Instance Method Summary collapse

Instance Method Details

#reloadDocument

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.

Examples:

Reload the document.

person.reload

Returns:

  • (Document)

    The document, reloaded.

Raises:



16
17
18
19
20
21
22
23
24
25
# File 'lib/mongoid/reloadable.rb', line 16

def reload
  reloaded = _reload
  check_for_deleted_document!(reloaded)

  reset_object!(reloaded)

  run_callbacks(:find) unless _find_callbacks.empty?
  run_callbacks(:initialize) unless _initialize_callbacks.empty?
  self
end