Module: Auth::Sanitizer::FilteredAttributes
- Defined in:
- lib/auth/sanitizer/filtered_attributes.rb
Overview
Mixin that redacts sensitive instance variables in #inspect output.
Classes include this module and declare attribute names to filter via filtered_attributes.
Matching and replacement behavior is delegated to {ThingFilter}, initialized once per object.
This means existing objects keep the filter configuration that was present when they were
initialized, even if global config or class-level filter declarations change later.
The label used for redaction is resolved from filtered_label
at object initialization time. Host gems may customize this by installing a
provider via filtered_label_provider=.
Defined Under Namespace
Modules: ClassMethods, InitializerMethods
Class Method Summary collapse
-
.included(base) ⇒ void
Hook invoked when the module is included.
Instance Method Summary collapse
-
#inspect ⇒ String
Custom inspect that redacts configured attributes.
-
#thing_filter ⇒ ThingFilter
The initialized thing filter used by this object.
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Hook invoked when the module is included. Extends the including class with
class-level helpers and prepends the initializer hook.
23 24 25 26 |
# File 'lib/auth/sanitizer/filtered_attributes.rb', line 23 def included(base) base.extend(ClassMethods) base.prepend(InitializerMethods) end |
Instance Method Details
#inspect ⇒ String
Custom inspect that redacts configured attributes.
94 95 96 97 98 99 |
# File 'lib/auth/sanitizer/filtered_attributes.rb', line 94 def inspect inspected = super return inspected if thing_filter.things.empty? redact_inspected_values(inspected.dup) end |
#thing_filter ⇒ ThingFilter
The initialized thing filter used by this object.
This is a per-instance snapshot created during initialization.
87 88 89 |
# File 'lib/auth/sanitizer/filtered_attributes.rb', line 87 def thing_filter @thing_filter end |