Class: AtlasEngine::AddressValidation::Validators::FullAddress::UnmatchedFieldConcernBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
ConcernFormatter
Defined in:
app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern_builder.rb

Constant Summary collapse

COMPONENTS_TO_LABELS =
{
  zip: "ZIP",
  province_code: "state",
  city: "city",
  street: "street name",
}.freeze
SHORTENED_COMPONENT_NAMES =
{
  province_code: :province,
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConcernFormatter

#country_name, #province_name

Constructor Details

#initialize(unmatched_component, matched_components, address, unmatched_field = nil) ⇒ UnmatchedFieldConcernBuilder

Returns a new instance of UnmatchedFieldConcernBuilder.



32
33
34
35
36
37
# File 'app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern_builder.rb', line 32

def initialize(unmatched_component, matched_components, address, unmatched_field = nil)
  @address = address
  @unmatched_component = unmatched_component
  @matched_components = matched_components
  @unmatched_field = unmatched_field || unmatched_component
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



11
12
13
# File 'app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern_builder.rb', line 11

def address
  @address
end

#matched_componentsObject (readonly)

Returns the value of attribute matched_components.



11
12
13
# File 'app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern_builder.rb', line 11

def matched_components
  @matched_components
end

#unmatched_componentObject (readonly)

Returns the value of attribute unmatched_component.



11
12
13
# File 'app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern_builder.rb', line 11

def unmatched_component
  @unmatched_component
end

#unmatched_fieldObject (readonly)

Returns the value of attribute unmatched_field.



11
12
13
# File 'app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern_builder.rb', line 11

def unmatched_field
  @unmatched_field
end

Instance Method Details

#build(suggestion_ids = []) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'app/models/atlas_engine/address_validation/validators/full_address/unmatched_field_concern_builder.rb', line 44

def build(suggestion_ids = [])
  Concern.new(
    code: code,
    field_names: field_names,
    message: message,
    type: T.must(Concern::TYPES[:warning]),
    type_level: 3,
    suggestion_ids: suggestion_ids,
  )
end