8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/insights/api/common/open_api/serializer.rb', line 8
def as_json(arg = {})
previous = super(:except => _excluded_attributes(arg))
encrypted_columns_set = (self.class.try(:encrypted_columns) || []).to_set
encryption_filtered = previous.except(*encrypted_columns_set)
return encryption_filtered unless arg.key?(:prefixes)
attrs = encryption_filtered.slice(*_schema_properties(arg).keys)
_schema_properties(arg).keys.each do |name|
next if attrs[name].nil?
attrs[name] = attrs[name].iso8601 if attrs[name].kind_of?(Time)
attrs[name] = attrs[name].to_s if name.ends_with?("_id") || name == "id"
end
attrs.compact
end
|