def files_content(record, identifier, path, frag_content)
      # preparing attachments
      files = frag_content.split("\n").collect do |filename|
        file_handler = File.open(File.join(path, filename))
        {
          io:           file_handler,
          filename:     filename,
          content_type: MimeMagic.by_magic(file_handler)
        }
      end

      # ensuring that old attachments get removed
      ids_destroy = []
      if (frag = record.fragments.find_by(identifier: identifier))
        ids_destroy = frag.attachments.pluck(:id)
      end

      [files, ids_destroy]
    end
def files_content(record, identifier, path, frag_content)
      # preparing attachments
      files = frag_content.split("\n").collect do |filename|
        file_handler = File.open(File.join(path, filename))
        {
          io:           file_handler,
          filename:     filename,
          content_type: MimeMagic.by_magic(file_handler)
        }
      end

      # ensuring that old attachments get removed
      ids_destroy = []
      if (frag = record.fragments.find_by(identifier: identifier))
        ids_destroy = frag.attachments.pluck(:id)
      end

      [files, ids_destroy]
    end
Preparing fragment attachments. Returns hashes with file data for
 ActiveStorage and a list of ids of old attachements to destroy