Class: AtlasEngine::CountryProfileValidationSubset

Inherits:
CountryProfileSubsetBase show all
Defined in:
app/models/atlas_engine/country_profile_validation_subset.rb

Instance Attribute Summary

Attributes inherited from CountryProfileSubsetBase

#attributes

Instance Method Summary collapse

Methods inherited from CountryProfileSubsetBase

#initialize

Constructor Details

This class inherits a constructor from AtlasEngine::CountryProfileSubsetBase

Instance Method Details

#address_parserObject



44
45
46
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 44

def address_parser
  attributes.dig("address_parser").constantize
end

#city_aliasObject



83
84
85
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 83

def city_alias
  attributes.dig("city_alias").nil? ? true : attributes.dig("city_alias")
end

#comparison_policy(field) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 54

def comparison_policy(field)
  field_policy = attributes.dig(
    "comparison_policies",
    field.to_s,
  )&.deep_symbolize_keys&.deep_transform_values!(&:to_sym)

  if field_policy.present?
    AddressValidation::Token::Sequence::ComparisonPolicy.new(**field_policy)
  else
    AddressValidation::Token::Sequence::ComparisonPolicy::DEFAULT_POLICY
  end
end

#component_comparison(component) ⇒ Object



73
74
75
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 73

def component_comparison(component)
  attributes.dig("address_comparison", component.to_s).constantize
end

#default_matching_strategyObject



12
13
14
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 12

def default_matching_strategy
  attributes.dig("default_matching_strategy")
end

#enabledObject



7
8
9
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 7

def enabled
  !!attributes.dig("enabled")
end

#index_localesObject



17
18
19
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 17

def index_locales
  attributes.dig("index_locales") || []
end

#multi_locale?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 22

def multi_locale?
  index_locales.size > 1
end

#normalized_componentsObject



49
50
51
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 49

def normalized_components
  attributes.dig("normalized_components") || []
end

#partial_postal_code_range(length) ⇒ Object



36
37
38
39
40
41
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 36

def partial_postal_code_range(length)
  range = attributes.dig("partial_postal_code_range_for_length", length)
  return unless range

  Range.new(*range.split("..").map(&:to_i))
end

#unmatched_components_suggestion_thresholdObject



68
69
70
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 68

def unmatched_components_suggestion_threshold
  attributes.dig("unmatched_components_suggestion_threshold") || 2
end

#validation_exclusions(component:) ⇒ Object



30
31
32
33
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 30

def validation_exclusions(component:)
  validation_exclusions = attributes.dig("exclusions", component.to_s) || []
  validation_exclusions.map(&:constantize)
end

#zip_prefix_lengthObject



78
79
80
# File 'app/models/atlas_engine/country_profile_validation_subset.rb', line 78

def zip_prefix_length
  attributes.dig("zip_prefix_length") || 0
end