module ResetCurrentThread

Constants

VERSION

Public Class Methods

all!() click to toggle source

Sets all items in the current thread and fiber local to nil

@return [Thread] current thread object.

# File lib/reset_current_thread.rb, line 11
def self.all!
  fiber_locals!
  thread_locals!
end
fiber_locals!() click to toggle source

Sets all items in the current thread fiber local to nil

@return [Thread] current thread object.

# File lib/reset_current_thread.rb, line 19
def self.fiber_locals!
  Thread.current.keys.each do |key|
    Thread.current[key] = nil
  end
  Thread.current
end
thread_locals!() click to toggle source

Sets all items in the current thread local to nil

@return [Thread] current thread object.

# File lib/reset_current_thread.rb, line 29
def self.thread_locals!
  Thread.current.thread_variables.each do |key|
    Thread.current.thread_variable_set(key, nil)
  end
  Thread.current
end