I’m trying to ensure that a variable value is non-nil before proceeding – the value is instantiated asynchronously depending on request activity at a Sinatra instance
attr_accessor :access_token
until !@access_token.nil?
@access_token = RestClient.get @callback_URI + '/access_token/' + @request_Id
end
puts @access_token #=> always get output even if @access_token is nil
My understanding is that the expression means: ‘keep assigning the value of the RestClient call to @access_token until it returns a non-nil value, and then exit the until block’. What have I done wrong? Many thanks!
I don’t know what your server returns, but I would try something like,