Ruby on Rails Wednesday, September 21, 2016

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?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/fb15e80a-63de-4a59-b187-a739b972cb0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment