class Restfulness::Sanitizer::Hash

Clean a hash of sensitive data. Works on nested hashes

Public Instance Methods

sanitize(h) click to toggle source
# File lib/restfulness/sanitizer.rb, line 34
def sanitize(h)
  return h if sensitive_params.empty? || h.empty?
  duplicate = h.dup
  duplicate.each_pair do |k, v|
    duplicate[k] = if sensitive_param?(k)
      SANITIZED
    elsif v.is_a?(::Hash)
      sanitize(v)
    else
      v
    end
  end
  duplicate
end