Module: Auth::Sanitizer::FilteredAttributes — Documentation by YARD 0.9.44

# 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 which attribute names should be
filtered via filtered_attributes. Matching and replacement behavior is
delegated to {ThingFilter}, which is 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.

Parameters:

- base (`Class`) —

  The including class

    25
    26
    27
    28
    # File 'lib/auth/sanitizer/filtered_attributes.rb', line 25

    def included(base)
      base.extend(ClassMethods)
      base.prepend(InitializerMethods)
    end

## Instance Method Details

### #inspect ⇒ `String`

Custom inspect that redacts configured attributes.

Returns:

- (`String`)

    95
    96
    97
    98
    99
    100
    # File 'lib/auth/sanitizer/filtered_attributes.rb', line 95

    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.

Returns:

- (`ThingFilter`)

    88
    89
    90
    # File 'lib/auth/sanitizer/filtered_attributes.rb', line 88

    def thing_filter
      @thing_filter
    end