lib/mongoid/association/referenced/syncable.rb
# Set up the sync of inverse keys that needs to happen on a save.
#
# If the foreign key field has changed and the document is not
# synced, $addToSet the new ids, $pull the ones no longer in the
# array from the inverse side.
#
# @example Set up the save syncing.
#   Person.synced_save(association)
#
# @param [ Association ] association The association metadata.
#
# @return [ Class ] The class getting set up.
Set up the sync of inverse keys that needs to happen on a save.
If the foreign key field has changed and the document is not
synced, $addToSet the new ids, $pull the ones no longer in the
array from the inverse side.
Set up the sync of inverse keys that needs to happen on a save . If the foreign key field has changed and the document is not synced $addToSet the new ids $pull the ones no longer in the array from the inverse side .
def synced_save(association)
            set_callback(
                :save,
                :after,
                if: ->(doc) { doc._syncable?(association) }
            ) do |doc|
              doc.update_inverse_keys(association)
            end
            self
          end
def synced_save ( association ) set_callback ( :save , :after , if : -> ( doc ) { doc . _syncable? ( association ) } ) do | doc | doc . update_inverse_keys ( association ) end self end
Set up the sync of inverse keys that needs to happen on a save.
Set up the sync of inverse keys that needs to happen on a save .
The class getting set up.
The class getting set up .
 Class 
association
<not_specific>
<not_specific>
association The association metadata.
association The association metadata .
example
Set up the save syncing. Person.synced_save(association)
Set up the save syncing . Person . synced_save ( association )