Class: JsonApiClient::Middleware::ParseJson

Inherits:
Faraday::Middleware
  • Object
show all
Defined in:
lib/json_api_client/middleware/parse_json.rb

Instance Method Summary collapse

Instance Method Details

#call(environment) ⇒ Object


5
6
7
8
9
10
11
12
# File 'lib/json_api_client/middleware/parse_json.rb', line 5

def call(environment)
  @app.call(environment).on_complete do |env|
    if process_response_type?(response_type(env))
      env[:raw_body] = env[:body]
      env[:body] = parse(env[:body])
    end
  end
end