Sha256: 3e8759120661e6e45275b40618690741411e111c20722022fe20233bf7a4fc06
Contents?: true
Size: 496 Bytes
Versions: 1
Compression:
Stored size: 496 Bytes
Contents
require 'faraday' require 'multi_json' module Hackeroo 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hackeroo-0.1.0 | lib/hackeroo/response/parse_json.rb |