pengwynn/faraday_middleware — pull request #31 by tylerhunt (2012-03-27 04:36:35+00:00)
Title: Only require 'json' if it's undefined.

In light of the recent MultiJSON removal and @mislav's comments on #30, this patch allows JSON Gems with a compatibility API to be used without the dependency defined on `FaradayMiddleware::ParseJson` overriding it when it's loaded.

This is purely a load order issue. If the following is run before `FaradayMiddleware::ParseJson` is loaded:

require 'yajl/json_gem'

this call to `Faraday::Middleware.dependency` in `FaradayMiddleware::ParseJson`:

dependency 'json'

would effectively cause a:

require 'json'

which would wipe out Yajl's JSON gem compatibility and replacing it with the actual JSON gem or stdlib library.