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
|
# File 'app/models/atlas_engine/address_validation/validators/full_address/suggestion_builder.rb', line 31
def from_comparisons(address, comparisons, candidate, unmatched_fields = {})
unmatched_address_keys = comparisons.keys.each_with_object([]) do |key, array|
array << if key == :street
unmatched_fields[:street]
else
key
end
end.append(:country_code).compact
suggestion = Suggestion.new(**T.unsafe(address).slice(*unmatched_address_keys))
comparisons.each do |key, comparison|
case key
when :street
suggest_street(suggestion, comparison, candidate, unmatched_fields)
when :city
suggest_city(suggestion, comparison, candidate, unmatched_fields)
when :zip
suggest_zip(suggestion, comparison, candidate, unmatched_fields)
when :province_code
suggest_province_code(suggestion, comparison, candidate, unmatched_fields)
end
end
suggestion.country_code = nil
suggestion
end
|