Module: ActiveSupport::IsolatedExecutionState

Defined in:
lib/active_support/isolated_execution_state.rb

Overview

:nodoc:

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.isolation_levelObject

Returns the value of attribute isolation_level.



13
14
15
# File 'lib/active_support/isolated_execution_state.rb', line 13

def isolation_level
  @isolation_level
end

Instance Attribute Details

#active_support_execution_stateObject

Returns the value of attribute active_support_execution_state.



9
10
11
# File 'lib/active_support/isolated_execution_state.rb', line 9

def active_support_execution_state
  @active_support_execution_state
end

Class Method Details

.[](key) ⇒ Object



32
33
34
# File 'lib/active_support/isolated_execution_state.rb', line 32

def [](key)
  current[key]
end

.[]=(key, value) ⇒ Object



36
37
38
# File 'lib/active_support/isolated_execution_state.rb', line 36

def []=(key, value)
  current[key] = value
end

.clearObject



48
49
50
# File 'lib/active_support/isolated_execution_state.rb', line 48

def clear
  current.clear
end

.delete(key) ⇒ Object



44
45
46
# File 'lib/active_support/isolated_execution_state.rb', line 44

def delete(key)
  current.delete(key)
end

.key?(key) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/active_support/isolated_execution_state.rb', line 40

def key?(key)
  current.key?(key)
end

.share_with(other) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/active_support/isolated_execution_state.rb', line 52

def share_with(other)
  # 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.
  context = @isolation_level == :thread ? Thread.current : Fiber.current
  context.active_support_execution_state = other.active_support_execution_state.dup
end

.unique_idObject



28
29
30
# File 'lib/active_support/isolated_execution_state.rb', line 28

def unique_id
  self[:__id__] ||= Object.new
end