diff --git a/lib/active_fedora/aggregation/list_source.rb b/lib/active_fedora/aggregation/list_source.rb index 097324628..20f69b07e 100644 --- a/lib/active_fedora/aggregation/list_source.rb +++ b/lib/active_fedora/aggregation/list_source.rb @@ -12,6 +12,14 @@ def save(*args) super end + ## + # @deprecated use #changes_applied instead + def clear_changed_attributes + Deprecation.warn self.class, "#clear_changed_attributes is deprecated, use ActiveModel::Dirty#changes_applied instead." + + clear_changes_information + end + def changed? super || ordered_self.changed? end diff --git a/lib/active_fedora/attributes.rb b/lib/active_fedora/attributes.rb index eb2c86f3a..7fd51b0d7 100644 --- a/lib/active_fedora/attributes.rb +++ b/lib/active_fedora/attributes.rb @@ -9,7 +9,30 @@ module Attributes include Serializers include PrimaryKey - after_save :changes_applied + after_save :clear_changed_attributes_or_changes_applied + # @deprecated use #changes_applied instead + def clear_changed_attributes + Deprecation.warn ActiveFedora::Attributes, "#clear_changed_attributes is deprecated, use ActiveModel::Dirty#changes_applied instead." + @previously_changed = changes + clear_attribute_changes(changes.keys) + end + + ## + # Call the deprecated method + # + # @deprecated use #changes_applied instead + # @api private + def clear_changed_attributes_or_changes_applied + return changes_applied if + method(:clear_changed_attributes).super_method.nil? || + method(:clear_changed_attributes).owner == ActiveFedora::Aggregation::ListSource + + Deprecation.warn self.class, "after_save callbacks to #clear_changed_attributes are deprecated. " / + "These calls will be removed in 14.0.0. If you are running Rails 6.0, " / + "it's likely your #clear_changed_attributes implementation is in " / + "conflict with new ActiveModel::Dirty behavior." + clear_changed_attributes + end end def attribute_names