Module: Mongoid::Relations::AutoSave

Extended by:
ActiveSupport::Concern
Included in:
Mongoid::Relations
Defined in:
lib/mongoid/relations/auto_save.rb

Overview

This module contains the behaviour for auto-saving relations in different collections.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#autosaved?true, false

Used to prevent infinite loops in associated autosaves.

Examples:

Is the document autosaved?

document.autosaved?

Returns:

  • (true, false)

    Has the document already been autosaved?

Since:

  • 3.0.0



23
24
25
# File 'lib/mongoid/relations/auto_save.rb', line 23

def autosaved?
  Threaded.autosaved?(self)
end

#begin_autosaveObject

Begin the associated autosave.

Examples:

Begin autosave.

document.begin_autosave

Since:

  • 3.0.0



33
34
35
# File 'lib/mongoid/relations/auto_save.rb', line 33

def begin_autosave
  Threaded.begin_autosave(self)
end

#exit_autosaveObject

Exit the associated autosave.

Examples:

Exit autosave.

document.exit_autosave

Since:

  • 3.0.0



43
44
45
# File 'lib/mongoid/relations/auto_save.rb', line 43

def exit_autosave
  Threaded.exit_autosave(self)
end