Method: ActiveSupport::IsolatedExecutionState.share_with
- Defined in:
- lib/active_support/isolated_execution_state.rb
.share_with(other, except: [], &block) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_support/isolated_execution_state.rb', line 58 def share_with(other, except: [], &block) # Action Controller streaming spawns a new thread and copy thread locals. # We do the same here for backward compatibility, but this is very much a hack # and streaming should be rethought. if state = other.active_support_execution_state copied_state = state.dup Array(except).each { |key| copied_state.delete(key) } end old_state, context.active_support_execution_state = context.active_support_execution_state, copied_state block.call ensure context.active_support_execution_state = old_state end |