lib/anony/strategies/overwrite.rb
# Apply the Overwrite strategy on the model instance, which applies each of the
# configured transformations and updates the :anonymised_at field if it exists.
#
# @param [ActiveRecord::Base] instance An instance of the model
Apply the Overwrite strategy on the model instance, which applies each of the
configured transformations and updates the :anonymised_at field if it exists.
Apply the Overwrite strategy on the model instance which applies each of the configured transformations and updates the : anonymised_at field if it exists .
def apply(instance)
        if !@anonymisable_fields.key?(:anonymised_at) &&
            @model_class.column_names.include?("anonymised_at")
          current_datetime(:anonymised_at)
        end
        @anonymisable_fields.each_key do |field|
          anonymise_field(instance, field)
        end
        result_fields = instance.changes.keys.map(&:to_sym).reject { |s| s == :anonymised_at }
        instance.save!
        Result.overwritten(result_fields)
      end
def apply ( instance ) if ! @anonymisable_fields . key? ( :anonymised_at ) && @model_class . column_names . include? ( "anonymised_at" ) current_datetime ( :anonymised_at ) end @anonymisable_fields . each_key do | field | anonymise_field ( instance , field ) end result_fields = instance . changes . keys . map ( & :to_sym ) . reject { | s | s == :anonymised_at } instance . save! Result . overwritten ( result_fields ) end
Apply the Overwrite strategy on the model instance, which applies each of the
configured transformations and updates the :anonymised_at field if it exists.
Apply the Overwrite strategy on the model instance which applies each of the configured transformations and updates the : anonymised_at field if it exists .
instance
<not_specific>
<not_specific>
instance An instance of the model
instance An instance of the model