Problem
Users adding Sorbet to their codebase are immediately greeted with type checker warnings:
app/models/editorial.rb:5: include must only contain constant literals https://srb.help/4002
5 | include ImageUploader::Attachment.new(:headline_image)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is because Sorbet doesn’t support dynamic includes like this (I can’t include links as a new user but look at the link in the code snippet above or Adopting Sorbet section within their docs page).
Proposal
Add an alternative way to add attachments to a model for Sorbet users.
Something like:
class Photo < Sequel::Model
include Shrine::Attachment
# Proposed new method
attachment_name :image
end
From a cursory glance at the codebase I didn’t see anything that would make this impossible/very hard to do but thought @janko and other contributors will have more context.