Class: Faraday::Response::MultiJson

Inherits:
Response::Middleware
  • Object
show all
Defined in:
lib/faraday/response/multi_json.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ MultiJson

Returns a new instance of MultiJson.



8
9
10
11
# File 'lib/faraday/response/multi_json.rb', line 8

def initialize(*args)
  super
  ::MultiJson.engine = :yajl
end

Instance Method Details

#on_complete(env) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/faraday/response/multi_json.rb', line 13

def on_complete(env)
  begin
    env[:body] = ::MultiJson.decode(env[:body])
  rescue MultiJson::ParserError
    env[:body] = nil
  end
end