Class: Ingenico::Direct::SDK::Logging::PropertyObfuscator
- Inherits:
-
Obfuscator
- Object
- Obfuscator
- Ingenico::Direct::SDK::Logging::PropertyObfuscator
- Defined in:
- lib/ingenico/direct/sdk/logging/logging_util.rb
Overview
Class that obfuscates properties in the JSON body of a message
Defined Under Namespace
Classes: Builder
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(obfuscators) ⇒ PropertyObfuscator
constructor
A new instance of PropertyObfuscator.
- #obfuscate(body) ⇒ Object
Methods inherited from Obfuscator
Constructor Details
#initialize(obfuscators) ⇒ PropertyObfuscator
Returns a new instance of PropertyObfuscator.
154 155 156 157 158 |
# File 'lib/ingenico/direct/sdk/logging/logging_util.rb', line 154 def initialize(obfuscators) # case sensitive super(obfuscators, false) @property_pattern = build_property_pattern(obfuscators.keys) end |
Class Method Details
Instance Method Details
#obfuscate(body) ⇒ Object
182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/ingenico/direct/sdk/logging/logging_util.rb', line 182 def obfuscate(body) return nil if body.nil? return "" if body.empty? body.gsub(@property_pattern) do m = Regexp.last_match property_name = m[2] value = m[4] || m[5] # copy value 'cause it's part of m[0] m[0].sub(value, obfuscate_value(property_name, value.dup)) end end |