module ActiveSupport::IsolatedExecutionState
Experimental RBS support (using type sampling data from the type_fusion project).
# sig/active_support/isolated_execution_state.rbs module ActiveSupport::IsolatedExecutionState type ActiveSupport__IsolatedExecutionState_[]_return_value = nil | Set | ActiveRecord::Scoping::ScopeRegistry | ActiveRecord::ExplainRegistry | Float def []: ((Symbol | String) key) -> ActiveSupport__IsolatedExecutionState_[]_return_value def []=: (Symbol key, Float value) -> Float def current_thread: () -> untyped end
def [](key)
Experimental RBS support (using type sampling data from the type_fusion project).
type ActiveSupport__IsolatedExecutionState_[]_return_value = nil | Set | ActiveRecord::Scoping::ScopeRegistry | ActiveRecord::ExplainRegistry | Float def []: ((Symbol | String) key) -> ActiveSupport__IsolatedExecutionState_[]_return_value
This signature was generated using 87 samples from 2 applications.
def [](key) current[key] end
def []=(key, value)
Experimental RBS support (using type sampling data from the type_fusion project).
def []=: (Symbol key, Float value) -> Float
This signature was generated using 2 samples from 1 application.
def []=(key, value) current[key] = value end
def clear
def clear current.clear end
def current_fiber
def current_fiber Fiber.current.active_support_execution_state ||= {} end
def current_thread
Experimental RBS support (using type sampling data from the type_fusion project).
def current_thread: () -> untyped
This signature was generated using 95 samples from 2 applications.
def current_thread Thread.current.active_support_execution_state ||= {} end
def delete(key)
def delete(key) current.delete(key) end
def isolation_level=(level)
def isolation_level=(level) unless %i(thread fiber).include?(level) raise ArgumentError, "isolation_level must be `:thread` or `:fiber`, got: `#{level.inspect}`" end if level != isolation_level clear singleton_class.alias_method(:current, "current_#{level}") singleton_class.send(:private, :current) @isolation_level = level end end
def key?(key)
def key?(key) current.key?(key) end
def share_with(other)
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
def unique_id
def unique_id self[:__id__] ||= Object.new end