Module: Gitlab::SensitiveSerializableHash

Extended by:
ActiveSupport::Concern
Includes:
SensitiveAttributes
Included in:
ApplicationRecord
Defined in:
app/models/concerns/gitlab/sensitive_serializable_hash.rb

Instance Method Summary collapse

Instance Method Details

#serializable_hash(options = nil) ⇒ Object

Override serializable_hash to exclude sensitive attributes by default

In general, prefer NOT to use serializable_hash / to_json / as_json in favor of serializers / entities instead which has an allowlist of attributes



24
25
26
27
28
29
30
31
32
33
# File 'app/models/concerns/gitlab/sensitive_serializable_hash.rb', line 24

def serializable_hash(options = nil)
  options = options.try(:dup) || {}
  options[:except] = Array(options[:except]).dup

  options[:except].concat self.class.attributes_exempt_from_serializable_hash

  options[:except].concat self.class.sensitive_attributes

  super(options)
end