Class: DebugBundle::Redaction::Redactor

Inherits:
Object
  • Object
show all
Defined in:
lib/debugbundle/redaction.rb

Instance Method Summary collapse

Constructor Details

#initialize(sensitive_fields: DEFAULT_SENSITIVE_FIELDS, max_depth: DEFAULT_MAX_DEPTH, max_string_length: DEFAULT_MAX_STRING_LENGTH, max_array_length: DEFAULT_MAX_ARRAY_LENGTH, max_hash_keys: DEFAULT_MAX_HASH_KEYS) ⇒ Redactor

Returns a new instance of Redactor.



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/debugbundle/redaction.rb', line 42

def initialize(
  sensitive_fields: DEFAULT_SENSITIVE_FIELDS,
  max_depth: DEFAULT_MAX_DEPTH,
  max_string_length: DEFAULT_MAX_STRING_LENGTH,
  max_array_length: DEFAULT_MAX_ARRAY_LENGTH,
  max_hash_keys: DEFAULT_MAX_HASH_KEYS
)
  @sensitive_terms = sensitive_fields.map { |field| compile_sensitive_term(field) }
  @max_depth = max_depth
  @max_string_length = max_string_length
  @max_array_length = max_array_length
  @max_hash_keys = max_hash_keys
end

Instance Method Details

#redact_value(value) ⇒ Object



56
57
58
# File 'lib/debugbundle/redaction.rb', line 56

def redact_value(value)
  sanitize(value, depth: 0, seen: {}.compare_by_identity)
end