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.
-
#message_format ⇒ Object
readonly
Returns the value of attribute message_format.
-
#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:, message_format:, unmatched_field: nil) ⇒ ConcernBuilder
constructor
A new instance of ConcernBuilder.
Constructor Details
#initialize(unmatched_component:, matched_components:, address:, suggestion_ids:, message_format:, unmatched_field: nil) ⇒ ConcernBuilder
Returns a new instance of ConcernBuilder.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 91 def initialize( unmatched_component:, matched_components:, address:, suggestion_ids:, message_format:, unmatched_field: nil ) @unmatched_component = unmatched_component @unmatched_field = unmatched_field @matched_components = matched_components @address = address @suggestion_ids = suggestion_ids @message_format = 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 |
#message_format ⇒ Object (readonly)
Returns the value of attribute message_format.
11 12 13 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 11 def @message_format 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
27 28 29 30 31 32 33 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 27 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
41 42 43 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 41 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
46 47 48 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 46 def valid_zip_for_province?(address) !country_has_zip_codes(address) || province_postal_code_valid?(address) end |
Instance Method Details
#build ⇒ Object
108 109 110 111 112 113 114 115 116 117 |
# File 'app/models/atlas_engine/address_validation/validators/full_address/concern_builder.rb', line 108 def build case unmatched_component when :zip build_zip_concern when :province_code build_province_concern else build_default_concern end end |