Class: Faraday::Response::Hashr

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

Instance Method Summary collapse

Instance Method Details

#on_complete(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/faraday/response/hashr.rb', line 7

def on_complete(env)
  begin
    if env[:body].is_a?(Array)
      env[:body] = env[:body].map { |o| ::Hashr.new(o) }
    else
      env[:body] = ::Hashr.new(env[:body])
    end
  rescue
    env[:body] = env[:body]
  end
end