Module: Lockbox::ActiveStorageExtensions::Attachment
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/lockbox/active_storage_extensions.rb
Instance Method Summary collapse
Instance Method Details
#download ⇒ Object
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/lockbox/active_storage_extensions.rb', line 93 def download result = super = Utils.(record, name) if result = Utils.decrypt_result(record, name, , result) end result end |
#mark_analyzed ⇒ Object
124 125 126 127 128 |
# File 'lib/lockbox/active_storage_extensions.rb', line 124 def mark_analyzed if Utils.(record, name) blob.update!(metadata: blob..merge(analyzed: true)) end end |
#open(**options) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/lockbox/active_storage_extensions.rb', line 105 def open(**) blob.open(**) do |file| = Utils.(record, name) if result = Utils.decrypt_result(record, name, , file.read) file.rewind # truncate may not be available on all platforms # according to the Ruby docs # may need to create a new temp file instead file.truncate(0) file.write(result) file.rewind end yield file end end |