This question is a little difficult to formulate, but I will do my best. There are fragments in our code, such as
response = do_something() return response unless response.ok?
I was thinking of creating a wrapper method that would eliminate the need for this step, and it would look something like this.
def rr(&block) response = yield unless response.ok?
After that, I could minimize the code above to be
response = rr { do_something() }
It seems impossible, but it's Ruby
, so maybe there is a way?
source share