Sha256: 55191fb76696d1a94c7b89de958cde90440b5741a132994625ab64c4ac8188a6

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

# This is the configuration for ImmutableStructExRedactable.
module ImmutableStructExRedactable
  class << self
    attr_reader :configuration

    # Returns the application configuration object.
    #
    # @return [Configuration] the application Configuration object.
    def configure
      self.configuration ||= Configuration.new

      yield(configuration) if block_given?

      configuration
    end

    private

    attr_writer :configuration
  end

  # This class encapsulates the configuration properties for this gem and
  # provides methods and attributes that allow for management of the same.
  class Configuration
    # Gets/sets the fields that should be redacted for this gem.
    #
    # The default is %i[password].
    #
    # @return [Array<Symbol>] an Array of Symbols that should be redacted.
    attr_accessor :redacted

    # Gets/sets the label that should replace redacted field values.
    #
    # The default is "******".
    #
    # @return [String] the label that should replace redacted field values.
    attr_accessor :redacted_label

    # The constructor; calls {#reset}.
    def initialize
      reset
    end

    # Resets the configuration settings to their default values.
    #
    # @return [void]
    def reset
      @redacted = %i[password]
      @redacted_label = '******'
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
immutable_struct_ex_redactable-1.1.0 lib/immutable_struct_ex_redactable/configuration.rb
immutable_struct_ex_redactable-1.0.0 lib/immutable_struct_ex_redactable/configuration.rb