Class: StartupStats::Response::ParseJson
- Inherits:
-
Faraday::Response::Middleware
- Object
- Faraday::Response::Middleware
- StartupStats::Response::ParseJson
- Defined in:
- lib/startupstats/response/parse_json.rb
Instance Method Summary collapse
Instance Method Details
#on_complete(env) ⇒ Object
17 18 19 20 21 |
# File 'lib/startupstats/response/parse_json.rb', line 17 def on_complete(env) if respond_to?(:parse) env[:body] = parse(env[:body]) unless [204, 301, 302, 304].include?(env[:status]) end end |
#parse(body) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/startupstats/response/parse_json.rb', line 8 def parse(body) case body when /\A^\s*$\z/, nil nil else MultiJson.load(body, :symbolize_keys => true) end end |