11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/verboten_keys/filterer.rb', line 11
def self.evaluate_key_value_pair(key, value)
key = key.to_sym
if VerbotenKeys.configuration.forbidden_keys.include?(key)
case VerbotenKeys.configuration.strategy
when :remove
return [nil, nil]
when :nullify
return [key, nil]
else
raise VerbotenKeys::Errors::StrategyNotFoundError(VerbotenKeys.configuration.strategy)
end
end
case value
when Hash
return [key, VerbotenKeys::Filterer.filter_forbidden_keys(value)]
when Array
return [key, value.map { |item| item.is_a?(Hash) ? VerbotenKeys::Filterer.filter_forbidden_keys(item) : item }]
end
[key, value]
end
|