Module: ActiveSupport::ExecutionContext
- Defined in:
- lib/active_support/execution_context.rb
Overview
:nodoc:
Defined Under Namespace
Modules: TestHelper
Class Method Summary collapse
- .[]=(key, value) ⇒ Object
- .after_change(&block) ⇒ Object
- .clear ⇒ Object
-
.set(**options) ⇒ Object
Updates the execution context.
- .to_h ⇒ Object
Class Method Details
permalink .[]=(key, value) ⇒ Object
[View source]
34 35 36 37 |
# File 'lib/active_support/execution_context.rb', line 34 def []=(key, value) store[key.to_sym] = value @after_change_callbacks.each(&:call) end |
permalink .after_change(&block) ⇒ Object
[View source]
7 8 9 |
# File 'lib/active_support/execution_context.rb', line 7 def after_change(&block) @after_change_callbacks << block end |
permalink .clear ⇒ Object
[View source]
43 44 45 |
# File 'lib/active_support/execution_context.rb', line 43 def clear store.clear end |
permalink .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/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 |
permalink .to_h ⇒ Object
[View source]
39 40 41 |
# File 'lib/active_support/execution_context.rb', line 39 def to_h store.dup end |