module Lockbox::ActiveStorageExtensions::AttachedMany
Public Instance Methods
attach(*attachables)
click to toggle source
Calls superclass method
# File lib/lockbox/active_storage_extensions.rb, line 55 def attach(*attachables) if encrypted? attachables = attachables.flatten.collect do |attachable| encrypt_attachable(attachable) end end super(attachables) end
rotate_encryption!()
click to toggle source
# File lib/lockbox/active_storage_extensions.rb, line 67 def rotate_encryption! raise "Not encrypted" unless encrypted? # must call to_a - do not change previous_attachments = attachments.to_a attachables = previous_attachments.map do |attachment| Utils.rebuild_attachable(attachment) end ActiveStorage::Attachment.transaction do attach(attachables) previous_attachments.each(&:purge) end attachments.reload true end