Module: ActiveSupport::ExecutionContext
Do not use. This module is for internal use only.
Relationships & Source Files | |
Namespace Children | |
Modules:
| |
Defined in: | activesupport/lib/active_support/execution_context.rb |
Class Method Summary
- .[]=(key, value)
- .after_change(&block)
- .clear
-
.set(**options)
Updates the execution context.
- .to_h
- .store private
Class Method Details
.[]=(key, value)
[ GitHub ]# File 'activesupport/lib/active_support/execution_context.rb', line 34
def []=(key, value) store[key.to_sym] = value @after_change_callbacks.each(&:call) end
.after_change(&block)
[ GitHub ]# File 'activesupport/lib/active_support/execution_context.rb', line 7
def after_change(&block) @after_change_callbacks << block end
.clear
[ GitHub ]# File 'activesupport/lib/active_support/execution_context.rb', line 43
def clear store.clear end
.set(**options)
Updates the execution context. If a block is given, it resets the provided keys to their previous value once the block exits.
# File 'activesupport/lib/active_support/execution_context.rb', line 13
def set(** ) .symbolize_keys! keys = .keys store = self.store previous_context = keys.zip(store.values_at(*keys)).to_h store.merge!( ) @after_change_callbacks.each(&:call) if block_given? begin yield ensure store.merge!(previous_context) @after_change_callbacks.each(&:call) end end end
.store (private)
[ GitHub ]# File 'activesupport/lib/active_support/execution_context.rb', line 48
def store IsolatedExecutionState[:active_support_execution_context] ||= {} end
.to_h
[ GitHub ]# File 'activesupport/lib/active_support/execution_context.rb', line 39
def to_h store.dup end