Sha256: e5eed70e9c6f3c3ea7b57750bf3ada53256c9a9681f11db92d50eca8764e3dd5
Contents?: true
Size: 1.39 KB
Versions: 38
Compression:
Stored size: 1.39 KB
Contents
module Appsignal module Utils # @api private class ParamsSanitizer FILTERED = "[FILTERED]".freeze class << self def sanitize(params, options = {}) sanitize_value(params, options) end private def sanitize_value(value, options = {}) case value when Hash sanitize_hash(value, options) when Array sanitize_array(value, options) when TrueClass, FalseClass, NilClass, Integer, String, Symbol, Float unmodified(value) else inspected(value) end end def sanitize_hash(source, options) filter_keys = options.fetch(:filter_parameters, []) {}.tap do |hash| source.each_pair do |key, value| hash[key] = if filter_keys.include?(key.to_s) FILTERED else sanitize_value(value, options) end end end end def sanitize_array(source, options) [].tap do |array| source.each_with_index do |item, index| array[index] = sanitize_value(item, options) end end end def unmodified(value) value end def inspected(value) "#<#{value.class}>" end end end end end
Version data entries
38 entries across 38 versions & 1 rubygems