class ActiveRecord::Scoping::ScopeRegistry
Experimental RBS support (using type sampling data from the type_fusion project).
# sig/active_record/scoping.rbs class ActiveRecord::Scoping::ScopeRegistry def current_scope: (*unused *, **unused **, , Class model, ?false skip_inherited_scope) -> nil def instance: () -> ActiveRecord::Scoping::ScopeRegistry def set_value_for: (Hash scope_type, Class model, false value) -> false def value_for: (Hash scope_type, Class model, ?false skip_inherited_scope) -> nil end
:nodoc:
You will obtain whatever was defined in some_new_scope.
registry.current_scope(Board)
Now when you run:
registry.set_current_scope(Board, some_new_scope)
registry = ActiveRecord::Scoping::ScopeRegistry
following code:
to get the current_scope for the Board model, then you would use the
classes and different types of scopes. For example, if you are attempting
This class allows you to store and get the scope values on different
local depending on the application configuration.
for different classes. The registry is stored as either a thread or fiber
This class stores the :current_scope and :ignore_default_scope values
def current_scope(model, skip_inherited_scope = false)
Experimental RBS support (using type sampling data from the type_fusion project).
def current_scope: (*unused *, **unused **, , Class model, ?false skip_inherited_scope) -> nil
This signature was generated using 46 samples from 2 applications.
def current_scope(model, skip_inherited_scope = false) value_for(@current_scope, model, skip_inherited_scope) end
def global_current_scope(model, skip_inherited_scope = false)
def global_current_scope(model, skip_inherited_scope = false) value_for(@global_current_scope, model, skip_inherited_scope) end
def ignore_default_scope(model, skip_inherited_scope = false)
def ignore_default_scope(model, skip_inherited_scope = false) value_for(@ignore_default_scope, model, skip_inherited_scope) end
def initialize
def initialize @current_scope = {} @ignore_default_scope = {} @global_current_scope = {} end
def instance
Experimental RBS support (using type sampling data from the type_fusion project).
def instance: () -> ActiveRecord::Scoping::ScopeRegistry
This signature was generated using 62 samples from 2 applications.
def instance ActiveSupport::IsolatedExecutionState[:active_record_scope_registry] ||= new end
def set_current_scope(model, value)
def set_current_scope(model, value) set_value_for(@current_scope, model, value) end
def set_global_current_scope(model, value)
def set_global_current_scope(model, value) set_value_for(@global_current_scope, model, value) end
def set_ignore_default_scope(model, value)
def set_ignore_default_scope(model, value) set_value_for(@ignore_default_scope, model, value) end
def set_value_for(scope_type, model, value)
Experimental RBS support (using type sampling data from the type_fusion project).
def set_value_for: (Micropost | FalseClass scope_type, Class model, false value) -> false
This signature was generated using 1 sample from 1 application.
def set_value_for(scope_type, model, value) scope_type[model.name] = value end
def value_for(scope_type, model, skip_inherited_scope = false)
Experimental RBS support (using type sampling data from the type_fusion project).
def value_for: (Types::Sample | NilClass scope_type, Class model, ?false skip_inherited_scope) -> nil
This signature was generated using 29 samples from 1 application.
def value_for(scope_type, model, skip_inherited_scope = false) return scope_type[model.name] if skip_inherited_scope klass = model base = model.base_class while klass <= base value = scope_type[klass.name] return value if value klass = klass.superclass end end