class BackupStorage::Attached

Abstract baseclass for the concrete `BackupStorage::Attached::One` and `BackupStorage::Attached::Many` classes that both provide proxy access to the blob association for a record.

Attributes

name[R]
record[R]

Public Class Methods

new(name, record) click to toggle source
# File lib/backup_storage/attached.rb, line 12
def initialize(name, record)
  @name, @record = name, record
end

Private Instance Methods

create_blob_from(attachable) click to toggle source
# File lib/backup_storage/attached.rb, line 17
def create_blob_from(attachable)
  case attachable
  when BackupStorage::Blob
    attachable
  when ActionDispatch::Http::UploadedFile
    BackupStorage::Blob.create_after_upload! \
      io: attachable.open,
      filename: attachable.original_filename,
      content_type: attachable.content_type
  when Hash
    BackupStorage::Blob.create_after_upload!(attachable)
  when String
    BackupStorage::Blob.find_signed(attachable)
  else
    nil
  end
end