Module: RequestStore::Fibers
- Defined in:
- lib/request_store/fibers.rb,
lib/request_store/fibers/version.rb
Overview
Make RequestStore work with fibers.
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
Class Method Details
.init ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/request_store/fibers.rb', line 12 def self.init @hook_id = Fiber.hook( new: -> { [RequestStore.store, RequestStore.active?] }, resume: ->(value) { RequestStore.store = value[0] if value[1] RequestStore.begin! else RequestStore.end! end } ) end |
.uninit ⇒ Object
26 27 28 29 30 31 |
# File 'lib/request_store/fibers.rb', line 26 def self.uninit raise Error, "You must init before you can uninit" unless @hook_id Fiber.unhook(@hook_id) @hook_id = nil end |