Module: ActiveRecord::AttributeMethods::Dirty

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

Overview

:nodoc:

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

#attribute_changed?, #attribute_was, #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.



37
38
39
40
41
42
# File 'activerecord/lib/active_record/attribute_methods/dirty.rb', line 37

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

#saveObject

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



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

def save(*)
  if status = super
    @previously_changed = changes
    @changed_attributes.clear
  end
  status
end

#save!Object

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



29
30
31
32
33
34
# File 'activerecord/lib/active_record/attribute_methods/dirty.rb', line 29

def save!(*)
  super.tap do
    @previously_changed = changes
    @changed_attributes.clear
  end
end