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? ⇒ Boolean
Check if there is changes for auto-saving.
-
#relation_changed_for_autosave(metadata) ⇒ Object
Returns the relation, if it exists.
Instance Method Details
#__autosaving__ ⇒ Object
Begin the associated autosave.
33 34 35 36 37 38 |
# File 'lib/mongoid/relations/auto_save.rb', line 33 def __autosaving__ Threaded.begin_autosave(self) yield ensure Threaded.exit_autosave(self) end |
#autosaved? ⇒ true, false
Used to prevent infinite loops in associated autosaves.
23 24 25 |
# File 'lib/mongoid/relations/auto_save.rb', line 23 def autosaved? Threaded.autosaved?(self) end |
#changed_for_autosave? ⇒ Boolean
Check if there is changes for auto-saving
document.changed_for_autosave?
47 48 49 |
# File 'lib/mongoid/relations/auto_save.rb', line 47 def changed_for_autosave? new_record? || changed? || marked_for_destruction? end |
#relation_changed_for_autosave(metadata) ⇒ Object
Returns the relation, if it exists
54 55 56 |
# File 'lib/mongoid/relations/auto_save.rb', line 54 def relation_changed_for_autosave() ivar(.name) if self.class.autosaved_relations.include?(.name) end |