Module: ActiveRecord::AutosaveAssociation

Extended by:
ActiveSupport::Concern
Defined in:
app/patches/rails/active_record/autosave_association.rb

Instance Method Summary collapse

Instance Method Details

#changed_for_autosave?Boolean

Returns whether or not this record has been changed in any way (including whether any of its nested autosave associations are likewise changed)

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/patches/rails/active_record/autosave_association.rb', line 13

def changed_for_autosave?
  @_changed_for_autosave_called ||= false
  if @_changed_for_autosave_called
    # traversing a cyclic graph of objects; stop it
    result = false
  else
    begin
      @_changed_for_autosave_called = true
      result = new_record? || changed? || marked_for_destruction? || nested_records_changed_for_autosave?
    ensure
      @_changed_for_autosave_called = false
    end
  end
  result
end