module Sequel::Plugins::ColumnEncryption::InstanceMethods
Public Instance Methods
reencrypt()
click to toggle source
Reencrypt the model if needed. Looks at all of the models encrypted columns and if any were encypted with older keys or a different format, reencrypt with the current key and format and save the object. Returns the object if reencryption was needed, or nil if reencryption was not needed.
# File lib/sequel/plugins/column_encryption.rb 708 def reencrypt 709 do_save = false 710 711 model.send(:column_encryption_metadata).each do |column, metadata| 712 if (value = values[column]) && !value.start_with?(metadata.key_searcher.call) 713 do_save = true 714 values[column] = metadata.encryptor.call(metadata.decryptor.call(value)) 715 end 716 end 717 718 save if do_save 719 end