I am calling the RestClient::Resource#get(additional_headers = {}, &block) method multiple times with the same block but on different Resources, I was wondering if there is a way to save the block into a variable, or to save it into a Proc convert it into a block each time.
Edit:
I did the following:
resource = RestClient::Resource.new('https://foo.com')
redirect = lambda do |response, request, result, &block|
if [301, 302, 307].include? response.code
response.follow_redirection(request, result, &block)
else
response.return!(request, result, &block)
end
end
@resp = resource.get (&redirect)
I get: Syntax error, unexpected tAMPER