Skip to content

Instantly share code, notes, and snippets.

@excid3
Created July 28, 2021 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save excid3/768a796286c96b7a69356b89641d23cb to your computer and use it in GitHub Desktop.
Save excid3/768a796286c96b7a69356b89641d23cb to your computer and use it in GitHub Desktop.
class Request
attr_reader :exception, :response
def initialize(context = {})
@context = context
end
def execute
@response ||= Response.call(execute_request)
self
rescue RestClient::BadRequest => err
@exception = err
self
end
def success?
@exception.nil? && @response.present?
end
private
def execute_request
RestClient::Request.execute(request_data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment