Class: Gemfury::Client::ParseJson

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/gemfury/client/middleware.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(response) ⇒ Object


17
18
19
20
# File 'lib/gemfury/client/middleware.rb', line 17

def on_complete(response)
  ok = response.request_headers['Accept'] =~ /json\z/
  response.body = parse(response.body) if ok
end

#parse(body) ⇒ Object


13
14
15
# File 'lib/gemfury/client/middleware.rb', line 13

def parse(body)
  body =~ /\A\s*\z/ ? nil : MultiJson.decode(body)
end