Module: ActiveRecord::AttributeMethods::Dirty

Extended by:
ActiveSupport::Concern
Includes:
ActiveModel::Dirty, Write
Defined in:
activerecord/lib/active_record/attribute_methods/dirty.rb

Constant Summary

Constants included from ActiveModel::AttributeMethods

ActiveModel::AttributeMethods::CALL_COMPILABLE_REGEXP, ActiveModel::AttributeMethods::NAME_COMPILABLE_REGEXP

Instance Method Summary collapse

Methods included from ActiveSupport::Concern

append_features, extended, included

Methods included from ActiveModel::Dirty

#changed, #changed?, #changed_attributes, #changes, #previous_changes

Methods included from ActiveModel::AttributeMethods

#attribute_missing, #method_missing, #respond_to?, #respond_to_without_attributes?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ActiveModel::AttributeMethods

Instance Method Details

#reloadObject

reload the record and clears changed attributes.



43
44
45
46
47
48
# File 'activerecord/lib/active_record/attribute_methods/dirty.rb', line 43

def reload(*) #:nodoc:
  super.tap do
    @previously_changed.clear
    @changed_attributes.clear
  end
end

#saveObject

Attempts to save the record and clears changed attributes if successful.



21
22
23
24
25
26
27
28
29
# File 'activerecord/lib/active_record/attribute_methods/dirty.rb', line 21

def save(*) #:nodoc:
  if status = super
    @previously_changed = changes
    @changed_attributes.clear
  elsif IdentityMap.enabled?
    IdentityMap.remove(self)
  end
  status
end

#save!Object

Attempts to save! the record and clears changed attributes if successful.



32
33
34
35
36
37
38
39
40
# File 'activerecord/lib/active_record/attribute_methods/dirty.rb', line 32

def save!(*) #:nodoc:
  super.tap do
    @previously_changed = changes
    @changed_attributes.clear
  end
rescue
  IdentityMap.remove(self) if IdentityMap.enabled?
  raise
end