Class: AtlasEngine::AddressValidation::Validators::FullAddress::ConcernBuilder
- Inherits:
-
Object
- Object
- AtlasEngine::AddressValidation::Validators::FullAddress::ConcernBuilder
- Extended by:
- T::Sig
- Defined in:
- app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#matched_components ⇒ Object
readonly
Returns the value of attribute matched_components.
-
#suggestion_ids ⇒ Object
readonly
Returns the value of attribute suggestion_ids.
-
#unmatched_component ⇒ Object
readonly
Returns the value of attribute unmatched_component.
-
#unmatched_field ⇒ Object
readonly
Returns the value of attribute unmatched_field.
Class Method Summary collapse
- .should_suggest?(address, unmatched_component_keys) ⇒ Boolean
- .too_many_unmatched_components?(address, unmatched_component_keys) ⇒ Boolean
- .valid_zip_for_province?(address) ⇒ Boolean
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(unmatched_component:, matched_components:, address:, suggestion_ids:, unmatched_field: nil) ⇒ ConcernBuilder
constructor
A new instance of ConcernBuilder.
Constructor Details
#initialize(unmatched_component:, matched_components:, address:, suggestion_ids:, unmatched_field: nil) ⇒ ConcernBuilder
Returns a new instance of ConcernBuilder.
85 86 87 88 89 90 91 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 85 def initialize(unmatched_component:, matched_components:, address:, suggestion_ids:, unmatched_field: nil) @unmatched_component = unmatched_component @unmatched_field = unmatched_field @matched_components = matched_components @address = address @suggestion_ids = suggestion_ids end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 11 def address @address end |
#matched_components ⇒ Object (readonly)
Returns the value of attribute matched_components.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 11 def matched_components @matched_components end |
#suggestion_ids ⇒ Object (readonly)
Returns the value of attribute suggestion_ids.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 11 def suggestion_ids @suggestion_ids end |
#unmatched_component ⇒ Object (readonly)
Returns the value of attribute unmatched_component.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 11 def unmatched_component @unmatched_component end |
#unmatched_field ⇒ Object (readonly)
Returns the value of attribute unmatched_field.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 11 def unmatched_field @unmatched_field end |
Class Method Details
.should_suggest?(address, unmatched_component_keys) ⇒ Boolean
22 23 24 25 26 27 28 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 22 def should_suggest?(address, unmatched_component_keys) return false if too_many_unmatched_components?(address, unmatched_component_keys) return false if province_and_city_xor_zip?(unmatched_component_keys) && !valid_zip_for_province?(address) true end |
.too_many_unmatched_components?(address, unmatched_component_keys) ⇒ Boolean
36 37 38 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 36 def too_many_unmatched_components?(address, unmatched_component_keys) unmatched_component_keys.size > unmatched_components_suggestion_threshold(address) end |
.valid_zip_for_province?(address) ⇒ Boolean
41 42 43 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 41 def valid_zip_for_province?(address) !country_has_zip_codes(address) || province_postal_code_valid?(address) end |
Instance Method Details
#build ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 94 def build case unmatched_component when :zip build_zip_concern when :province_code build_province_concern else build_default_concern end end |