123456789_123456789_123456789_123456789_123456789_

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

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.

[ GitHub ]

  
# File 'activesupport/lib/active_support/execution_context.rb', line 13

def set(**options)
  options.symbolize_keys!
  keys = options.keys

  store = self.store

  previous_context = keys.zip(store.values_at(*keys)).to_h

  store.merge!(options)
  @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