ActiveStorage Callbacks

I’m not sure how common this is, but wondering if its worth working on a PR for ActiveStorage to allow you to use callbacks. Something like this for example to run a method after analyze is complete:

has_one_attached :artwork, after_analyze: :my_method

I had a similar need – in my case I want to insert a cover letter at page 1 of a PDF attachment – and I came up with this:

https://gist.github.com/benwalsh/d611608ea9f4ff6e1ec1efd0d3755b37

In the model, then:

include ActiveStorageCallbacks

perform_attach welcome_pack: { before: :insert_cover_letter }

``

I tried a more sophisticated approach that injected the custom callback into the callback chain but it was hard so I gave up.