Class: OnlinePayments::SDK::Logging::PropertyObfuscator
- Inherits:
-
Obfuscator
- Object
- Obfuscator
- OnlinePayments::SDK::Logging::PropertyObfuscator
- Defined in:
- lib/onlinepayments/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.
167 168 169 170 171 |
# File 'lib/onlinepayments/sdk/logging/logging_util.rb', line 167 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
195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/onlinepayments/sdk/logging/logging_util.rb', line 195 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 |