Module: ActiveSupport::ExecutionContext

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/execution_context.rb

Overview

:nodoc:

Defined Under Namespace

Modules: TestHelper

Class Method Summary collapse

Class Method Details

.[]=(key, value) ⇒ Object



34
35
36
37
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/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) ⇒ Object



7
8
9
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/execution_context.rb', line 7

def after_change(&block)
  @after_change_callbacks << block
end

.clearObject



43
44
45
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/execution_context.rb', line 43

def clear
  store.clear
end

.set(**options) ⇒ Object

Updates the execution context. If a block is given, it resets the provided keys to their previous value once the block exits.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/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

.to_hObject



39
40
41
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/execution_context.rb', line 39

def to_h
  store.dup
end