Module: RefreshThreadCurrent

Defined in:
lib/refresh_thread_current.rb,
lib/refresh_thread_current/version.rb,
lib/refresh_thread_current/middleware.rb

Defined Under Namespace

Classes: Middleware

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.clear_all_local_variables ⇒ Object



8
9
10
11
# File 'lib/refresh_thread_current.rb', line 8

def clear_all_local_variables
  clear_thread_local_variables
  clear_fiber_local_variables
end

.clear_fiber_local_variables ⇒ Object



19
20
21
# File 'lib/refresh_thread_current.rb', line 19

def clear_fiber_local_variables
  Thread.current.keys.each { |key| Thread.current[key] = nil }
end

.clear_thread_local_variables ⇒ Object



13
14
15
16
17
# File 'lib/refresh_thread_current.rb', line 13

def clear_thread_local_variables
  Thread.current.thread_variables.each do |key|
    Thread.current.thread_variable_set(key, nil)
  end
end