I asked my Twitter community which HTTP client to use. Certainly not HTTParty, because cool people don’t use HTTParty anymore. One takes these risks when one falls out of the loop with the latest and greatest tools.
I know convention over configuration is common in Ruby programming, but it strikes me that the API of the Faraday object being constructed does not *always* require an adapter as a strong dependency. Forgive my Java:
new Faraday(new FaradayDefaultAdapter()).addMiddleware(...)
I think this "defaulting" is leading you to some strong coupling to the Adapter, which we know can be a problem if you want to unit test your requests. The documentation shows you'll need to pass in a test Adapter:
test = Faraday.new do |builder| builder.adapter :test end
(there is also the now-classic problem of accidentally charging a real credit card during test runs: http://misko.hevery.com/200... describes it better than me)
I'd rather couple myself to Faraday by *intent* ("I want the default stack"), than by implementation details (knowing what the "default stack" includes and how to instantiate the pieces and in which order to apply them). If, later, I need those details, then I simply inline `withSensibleDefaultStack()` and I can see how it's done.
I love Misko's article. Warning people about singletons started my career. http://www.ibm.com/develope... I don't want a singleton: I want Faraday to hide some implementation details from me without making it impossible for me to gain access to them when, later, I need them. I think my proposal achieves that.