Last active
March 28, 2019 12:25
-
-
Save BitOfUniverse/8558b04f5ccd845f5605ad1dabbc5285 to your computer and use it in GitHub Desktop.
Ruby implicit block capture
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new(url = nil, options = nil) | |
block = block_given? ? Proc.new : nil | |
options = options ? default_connection_options.merge(options) : default_connection_options | |
Faraday::Connection.new(url, options, &block) | |
end | |
# And it should be used like this: | |
conn = Faraday.new(:url => 'https://www.smartly.io/developer') do |faraday| | |
faraday.request :url_encoded # form-encode POST params | |
faraday.response :logger # log requests to STDOUT | |
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment