Class: Etna::Censor
- Inherits:
-
Object
- Object
- Etna::Censor
- Defined in:
- lib/etna/censor.rb
Instance Method Summary collapse
-
#initialize(log_redact_keys) ⇒ Censor
constructor
A new instance of Censor.
- #redact(key, value) ⇒ Object
- #redact_keys ⇒ Object
Constructor Details
#initialize(log_redact_keys) ⇒ Censor
Returns a new instance of Censor.
3 4 5 |
# File 'lib/etna/censor.rb', line 3 def initialize(log_redact_keys) @log_redact_keys = log_redact_keys end |
Instance Method Details
#redact(key, value) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/etna/censor.rb', line 11 def redact(key, value) # Redact any values for the supplied key values, so they # don't appear in the logs. return compact(value) unless redact_keys if redact_keys.include?(key) return "*" elsif value.is_a?(Hash) redacted_value = value.map do |value_key, value_value| [value_key, redact(value_key, value_value)] end.to_h return redacted_value end return compact(value) end |
#redact_keys ⇒ Object
7 8 9 |
# File 'lib/etna/censor.rb', line 7 def redact_keys @log_redact_keys end |