module Faraday::Bang

Constants

ERROR_CODES
SUPPORTED_HTTP_METHODS

Public Instance Methods

options!(*args, &block) click to toggle source
# File lib/faraday_bang/bang.rb, line 12
def options!(*args, &block)
  url, body, headers = args
  response = run_request(:options, url, body, headers, &block)
  handle_response(response)
end

Private Instance Methods

handle_response(response) click to toggle source
# File lib/faraday_bang/bang.rb, line 19
def handle_response(response)
  if response.status >= 400
    err_name = "Response#{response.status}Error"
    if Faraday::Bang.const_defined?(err_name)
      klass = Faraday::Bang.const_get(err_name)
      raise klass.new(response)
    else
      raise Faraday::Bang::ResponseError.new(response)
    end
  end
  response
end