Method: ActiveData::Model::Associations::ReferencesMany#apply_changes

Defined in:
lib/active_data/model/associations/references_many.rb

#apply_changesObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/active_data/model/associations/references_many.rb', line 21

def apply_changes
  target.all? do |object|
    if object
      if object.marked_for_destruction? && reflection.autosave?
        object.destroy
      elsif object.new_record? || (reflection.autosave? && object.changed?)
        persist_object(object)
      else
        true
      end
    else
      true
    end
  end
end