Sha256: 68ca5255776e4c8d49a8226b15cd56be10034cf3867a6938e9fb6c1bc1febbac
Contents?: true
Size: 495 Bytes
Versions: 8
Compression:
Stored size: 495 Bytes
Contents
require 'faraday' require 'multi_json' module Twitter module Response class ParseJson < Faraday::Response::Middleware def parse(body) case body when /\A^\s*$\z/, nil nil else MultiJson.decode(body, :symbolize_keys => true) end end def on_complete(env) if respond_to?(:parse) env[:body] = parse(env[:body]) unless [204, 301, 302, 304].include?(env[:status]) end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems