Module: AuthSanitizer::Loader — Documentation by YARD 0.9.44

# Module: AuthSanitizer::Loader

Defined in:
  lib/auth_sanitizer/loader.rb

## Overview

Loader for consumers that need Auth::Sanitizer without defining a top-level
Auth constant in the host application.

## Constant Summary collapse

FILES =

      %w[
        auth/sanitizer/version.rb
        auth/sanitizer/thing_filter.rb
        auth/sanitizer/core.rb
        auth/sanitizer/filtered_attributes.rb
        auth/sanitizer/sanitized_logger.rb
      ].freeze

## Class Method Summary collapse

- .load_isolated ⇒ Module

  Load Auth::Sanitizer into an anonymous namespace and return the nested Auth::Sanitizer module from that namespace.

## Class Method Details

### .load_isolated ⇒ `Module`

Load Auth::Sanitizer into an anonymous namespace and return the
nested Auth::Sanitizer module from that namespace.

This uses Module#module_eval with explicit file and line metadata so it
works on Ruby 2.2+, where Kernel.load(path, module) is unavailable.

Returns:

- (`Module`) —

  isolated Auth::Sanitizer module

    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    # File 'lib/auth_sanitizer/loader.rb', line 23

    def load_isolated
      namespace = Module.new
      auth_namespace = Module.new
      namespace.const_set(:Auth, auth_namespace)

      FILES.each do |relative_path|
        path = File.expand_path("../#{relative_path}", __dir__)
        auth_namespace.module_eval(isolated_source(path), path, 1)
      end

      namespace.const_get(:Auth).const_get(:Sanitizer)
    end