Created
June 18, 2019 16:13
-
-
Save choallin/ab13c168690fb4f2cc5ac679f04424b8 to your computer and use it in GitHub Desktop.
This file contains 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
4.times.map do | |
t = Thread.current | |
t["#{dynamic_variable_name}".to_sym] = method_call | |
end | |
joined_threads = threads.map &:join | |
joined_threads.each do |t| | |
# The keys method returns all thread local variables by names | |
# analog to the Hash#keys method | |
t.keys.each do |key| | |
k = key.to_s.downcase | |
next if k.start_with?("active") || k.start_with?("__") | |
# In this example we want to have access to all this variables | |
# as an instance variabel e.g. to use them in a Rails view | |
instance_variable_set "@#{key}", t[key] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment