Module: Lockbox::ActiveStorageExtensions::CreateOne

Defined in:
lib/lockbox/active_storage_extensions.rb

Instance Method Summary collapse

Instance Method Details

#initialize(name, record, attachable) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/lockbox/active_storage_extensions.rb', line 90

def initialize(name, record, attachable)
  # this won't encrypt existing blobs
  # ideally we'd check metadata for the encrypted flag
  # and disallow unencrypted blobs
  # since they'll raise an error on decryption
  # but earlier versions of Lockbox won't have it
  attachable = Lockbox::Utils.encrypt_attachable(record, name, attachable) if Lockbox::Utils.encrypted?(record, name) && !attachable.is_a?(ActiveStorage::Blob)
  super(name, record, attachable)
end