class Arisaid::Faraday::Response

Public Instance Methods

call(env) click to toggle source
# File lib/arisaid/faraday/response.rb, line 4
def call(env)
  @app.call(env).on_complete do |_env|
    show_response(_env) if Arisaid.debug? && defined?(AwesomePrint)
  end
end
show_response(env) click to toggle source
# File lib/arisaid/faraday/response.rb, line 10
def show_response(env)
  require 'awesome_print'

  env.response.to_hash.slice(*valid_debug_attributes).each do |k, v|
    if k == :body
      k = :response_body
      v = Sawyer::Agent.serializer.decode(v)
    end

    puts "#{k}:"
    ap v
  end
end
valid_debug_attributes() click to toggle source
# File lib/arisaid/faraday/response.rb, line 24
def valid_debug_attributes
  %i(
    status
    body
    response_headers
  )
end