Method: Mongoid::Threaded#reset!
- Defined in:
- lib/mongoid/threaded.rb
#reset! ⇒ Object
Resets the current thread- or fiber-local storage to its initial state. This is useful for making sure the state is clean when starting a new thread or fiber.
The value of Mongoid::Config.real_isolation_level is used to determine whether to reset the storage for the current thread or fiber.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/mongoid/threaded.rb', line 47 def reset! case Config.real_isolation_level when :thread Thread.current.thread_variable_set(STORAGE_KEY, nil) when :fiber Fiber[STORAGE_KEY] = nil else raise "Unknown isolation level: #{Config.real_isolation_level.inspect}" end end |