Module: GoodJob::SafeState
- Defined in:
- lib/good_job/safe_state.rb
Overview
Execution-local storage with a compatibility fallback. Uses ActiveSupport::IsolatedExecutionState on Rails 7.0+ (which respects config.active_support.isolation_level = :fiber for Fiber-aware servers). Falls back to Thread.current on older Rails.
Class Method Summary collapse
Class Method Details
.[](key) ⇒ Object
9 10 11 |
# File 'lib/good_job/safe_state.rb', line 9 def self.[](key) state[key] end |
.[]=(key, value) ⇒ Object
13 14 15 |
# File 'lib/good_job/safe_state.rb', line 13 def self.[]=(key, value) state[key] = value end |
.delete(key) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/good_job/safe_state.rb', line 17 def self.delete(key) if defined?(ActiveSupport::IsolatedExecutionState) ActiveSupport::IsolatedExecutionState.delete(key) else Thread.current[key] = nil end end |