HTTParty::Response doesn’t like tap

A small surprise by hacking rivendell-api, if you try to use Object#tap on HTTParty::Response like this :

self.class.post(...) do |response|
  response.error! unless response.success?
end

The response instance won’t find these HTTParty::Response #error! or #success? methods (?).

In fact, the response variable isn’t a HTTParty::Response because of HTTParty::Response#method_missing which delegates the #tap method the parsed_response :-/

Without a tap, these 3 lines work fine :

response = self.class.post(...)
response.error! unless response.success?
response