Module: ActiveRecord::AttributeMethods::Dirty
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveModel::Dirty
- Defined in:
- lib/active_record/attribute_methods/dirty.rb
Overview
:nodoc:
Instance Method Summary collapse
- #attribute_changed_in_place?(attr_name) ⇒ Boolean
- #changed_attributes ⇒ Object
- #changes ⇒ Object
- #changes_applied ⇒ Object
- #clear_changes_information ⇒ Object
-
#initialize_dup(other) ⇒ Object
:nodoc:.
-
#reload ⇒ Object
reload
the record and clears changed attributes. -
#save ⇒ Object
Attempts to
save
the record and clears changed attributes if successful. -
#save! ⇒ Object
Attempts to
save!
the record and clears changed attributes if successful.
Instance Method Details
#attribute_changed_in_place?(attr_name) ⇒ Boolean
73 74 75 76 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 73 def attribute_changed_in_place?(attr_name) old_value = original_raw_attribute(attr_name) @attributes[attr_name].changed_in_place_from?(old_value) end |
#changed_attributes ⇒ Object
57 58 59 60 61 62 63 64 65 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 57 def changed_attributes # This should only be set by methods which will call changed_attributes # multiple times when it is known that the computed value cannot change. if defined?(@cached_changed_attributes) @cached_changed_attributes else super.reverse_merge(attributes_changed_in_place).freeze end end |
#changes ⇒ Object
67 68 69 70 71 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 67 def changes cache_changed_attributes do super end end |
#changes_applied ⇒ Object
47 48 49 50 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 47 def changes_applied super store_original_raw_attributes end |
#clear_changes_information ⇒ Object
52 53 54 55 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 52 def clear_changes_information super original_raw_attributes.clear end |
#initialize_dup(other) ⇒ Object
:nodoc:
41 42 43 44 45 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 41 def initialize_dup(other) # :nodoc: super @original_raw_attributes = nil calculate_changes_from_defaults end |
#reload ⇒ Object
reload
the record and clears changed attributes.
35 36 37 38 39 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 35 def reload(*) super.tap do clear_changes_information end end |
#save ⇒ Object
Attempts to save
the record and clears changed attributes if successful.
20 21 22 23 24 25 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 20 def save(*) if status = super changes_applied end status end |
#save! ⇒ Object
Attempts to save!
the record and clears changed attributes if successful.
28 29 30 31 32 |
# File 'lib/active_record/attribute_methods/dirty.rb', line 28 def save!(*) super.tap do changes_applied end end |