ActiveSupport callbacks

Hi everyone,

I’ve been struggling with something for a while and was hoping someone who knows more about me than this would be able to help. I have this gist: https://gist.github.com/kddeisz/d975ef9a5e45a88bacb03e9f2c1fcf67. I’m attempting to build in generic callbacks that I can port into a number of our gems here (this is not an invitation for a discussion on the merits of callbacks).

I’ve got them working nicely for before and after callbacks. My issue comes with around callbacks. I can get them to work if I explicitly look for a block argument and call it (as in this line: https://gist.github.com/kddeisz/d975ef9a5e45a88bacb03e9f2c1fcf67#file-main-rb-L30) but I can’t get it to work if I yield (as in this line: https://gist.github.com/kddeisz/d975ef9a5e45a88bacb03e9f2c1fcf67#file-main-rb-L35).

No matter how much I mess with it I can’t get it working. The thing is, I know this is a solvable problem because Rails does this in this file: https://github.com/rails/rails/blame/master/activesupport/lib/active_support/callbacks.rb, so there has to be a way. Unfortunately, I can’t seem to replicate the approach.

Help?