Class: ImmutableStructExRedactable::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/immutable_struct_ex_redactable/configuration.rb

Overview

This class encapsulates the configuration properties for this gem and provides methods and attributes that allow for management of the same.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

The constructor; calls #reset.



62
63
64
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 62

def initialize
  reset
end

Instance Attribute Details

#blacklistArray<Symbol> Also known as: redacted

Gets/sets the blacklisted fields that should be redacted for this gem.

The default is %i.

Returns:

  • (Array<Symbol>)

    an Array of Symbols that should be redacted.



32
33
34
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 32

def blacklist
  @blacklist
end

#redacted_labelString

Gets/sets the label that should replace redacted field values.

The default is “******”.

Returns:

  • (String)

    the label that should replace redacted field values.



48
49
50
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 48

def redacted_label
  @redacted_label
end

#redacted_unsafeBool

Gets/sets the redacted unsafe switch that determines whether or not redacted field values are retained as private methods named #unredacted_<field> on the struct returned. If this configuration property is true, redacted field values will be retained and accessible as private methods on the struct.

The default is false.

Returns:

  • (Bool)

    the unsafe switch value.



59
60
61
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 59

def redacted_unsafe
  @redacted_unsafe
end

#whitelistArray<Symbol>

Gets/sets the whitelisted fields that should not be redacted for this gem.

The default is [].

Returns:

  • (Array<Symbol>)

    an Array of Symbols that should be whitelisted.



41
42
43
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 41

def whitelist
  @whitelist
end

Instance Method Details

#redacted_unsafe?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 66

def redacted_unsafe?
  @redacted_unsafe
end

#resetvoid

This method returns an undefined value.

Resets the configuration settings to their default values.



73
74
75
76
77
78
# File 'lib/immutable_struct_ex_redactable/configuration.rb', line 73

def reset
  @blacklist = %i[password]
  @whitelist = []
  @redacted_label = '******'
  @redacted_unsafe = false
end