Module: Lockbox::ActiveStorageExtensions::AttachedMany
- Defined in:
- lib/lockbox/active_storage_extensions.rb
Instance Method Summary collapse
Instance Method Details
#attach(*attachables) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/lockbox/active_storage_extensions.rb', line 48 def attach(*attachables) if encrypted? attachables = attachables.flatten.collect do |attachable| encrypt_attachable(attachable) end end super(attachables) end |
#rotate_encryption! ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/lockbox/active_storage_extensions.rb', line 60 def rotate_encryption! raise "Not encrypted" unless encrypted? # must call to_a - do not change = .to_a attachables = .map do || rebuild_attachable() end ActiveStorage::Attachment.transaction do attach(attachables) .each(&:purge) end .reload true end |