16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'projects/detached_entity/src/remove_sensitive_values_transformer_extensions.rb', line 16
def create_all_association_types_in_current_namespace(type)
already_sanitized = Set.new
associations = Foobara::DetachedEntity.construct_deep_associations(type)
associations&.values&.reverse&.each do |entity_type|
next if already_sanitized.include?(entity_type)
next if entity_type.sensitive?
unless entity_type.has_sensitive_types?
already_sanitized << entity_type
next
end
ns = Namespace.current
declaration = entity_type.declaration_data
sanitized_type_declaration = TypeDeclarations.remove_sensitive_types(declaration)
existing_type = ns.foobara_lookup(
entity_type.full_type_symbol,
mode: Namespace::LookupMode::ABSOLUTE_SINGLE_NAMESPACE
)
if existing_type
if existing_type.declaration_data == sanitized_type_declaration
already_sanitized << entity_type
already_sanitized << existing_type
next
else
raise "Did not expect to be re-sanitizing #{entity_type.full_type_symbol}"
end
end
Domain.current.foobara_type_from_declaration(sanitized_type_declaration)
already_sanitized << entity_type
end
end
|