Class: Credly::Response::ParseJson

Inherits:
Faraday::Response::Middleware
  • Object
show all
Defined in:
lib/credly/response/parse_json.rb

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



4
5
6
7
8
# File 'lib/credly/response/parse_json.rb', line 4

def on_complete(env)
  if respond_to? :parse
    env[:body] = parse(env[:body]) unless [204,302,304,307].index env[:status]
  end
end

#parse(body) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/credly/response/parse_json.rb', line 10

def parse(body)
  case body
  when ''
    nil
  else
    response_hash = ::MultiJson.decode(body)
  end
end