class Grape::Validations::ParamScopeTracker
Use .current to access the instance for the running request.
Lifecycle is managed by Endpoint#run_validators via .track.
objects can serve as keys without relying on value equality.
instances. Both trackers are identity-keyed hashes so that ParamsScope
Holds per-request mutable state that must not live on shared ParamsScope
def self.current
def self.current Fiber[FIBER_KEY] end
def self.track
def self.track previous = Fiber[FIBER_KEY] Fiber[FIBER_KEY] = new yield ensure Fiber[FIBER_KEY] = previous end
def index_for(scope)
def index_for(scope) index_tracker[scope] end
def index_tracker
def index_tracker @index_tracker ||= {}.compare_by_identity end
def qualifying_params(scope)
Note: an explicitly stored empty array and "never stored" are treated identically
Returns qualifying params for +scope+, or EMPTY_PARAMS if none were stored.
def qualifying_params(scope) qualifying_params_tracker.fetch(scope, EMPTY_PARAMS) end
def qualifying_params_tracker
def qualifying_params_tracker @qualifying_params_tracker ||= {}.compare_by_identity end
def store_index(scope, index)
def store_index(scope, index) index_tracker.store(scope, index) end
def store_qualifying_params(scope, params)
def store_qualifying_params(scope, params) qualifying_params_tracker.store(scope, params) end