class Auth::Sanitizer::ThingFilter
Small value object for matching and filtering named things.
Used by multiple filtering surfaces in the library, such as inspected object attributes and debug-log key filtering.
‘ThingFilter` snapshots and duplicates its inputs on initialization so later mutation of caller-owned arrays or strings does not affect existing filter instances.
Attributes
The configured replacement label.
@return [String]
Build a regular-expression source for the configured thing names.
Useful when a filtering surface needs regex-based replacement rather than direct name checks.
@return [String]
The configured names that should be filtered.
@return [Array<String>]
Public Class Methods
Create a new filter.
@param [Enumerable<#to_s>] things Names that should be filtered @param [String] label Replacement label to use for filtered values
The provided values are duplicated and frozen so the filter remains stable for the lifetime of the object.
# File lib/auth/sanitizer/thing_filter.rb 21 def initialize(things, label:) 22 @things = Array(things).map { |thing| thing.to_s.dup.freeze }.freeze 23 @label = label.to_s.dup.freeze 24 @pattern_source = Regexp.union(@things).source.freeze 25 end
Public Instance Methods
True when the provided name matches any configured filter entry.
Matching is substring-based so it works naturally with instance-variable names used by ‘#inspect`, such as `@secret` matching `secret`.
@param [#to_s] thing_name Candidate thing name @return [Boolean]
# File lib/auth/sanitizer/thing_filter.rb 44 def filtered?(thing_name) 45 thing_name_str = thing_name.to_s 46 things.any? { |thing| thing_name_str.include?(thing) } 47 end