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
-
#__autosaving__ ⇒ Object
Begin the associated autosave.
-
#autosaved? ⇒ true, false
Used to prevent infinite loops in associated autosaves.
-
#changed_for_autosave?(doc) ⇒ Boolean
Check if there is changes for auto-saving.
Instance Method Details
#__autosaving__ ⇒ Object
Begin the associated autosave.
28 29 30 31 32 33 |
# File 'lib/mongoid/relations/auto_save.rb', line 28 def __autosaving__ Threaded.begin_autosave(self) yield ensure Threaded.exit_autosave(self) end |
#autosaved? ⇒ true, false
Used to prevent infinite loops in associated autosaves.
18 19 20 |
# File 'lib/mongoid/relations/auto_save.rb', line 18 def autosaved? Threaded.autosaved?(self) end |
#changed_for_autosave?(doc) ⇒ Boolean
Check if there is changes for auto-saving
document.changed_for_autosave?
42 43 44 |
# File 'lib/mongoid/relations/auto_save.rb', line 42 def changed_for_autosave?(doc) doc.new_record? || doc.changed? || doc.marked_for_destruction? end |