Class: AtlasEngine::AddressValidation::Validators::FullAddress::UnknownProvinceConcernBuilder

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConcernFormatter

#country_name, #province_name

Constructor Details

#initialize(address, message_format = MessageFormat::Instructional) ⇒ UnknownProvinceConcernBuilder

Returns a new instance of UnknownProvinceConcernBuilder.



18
19
20
21
# File 'app/models/atlas_engine/address_validation/validators/full_address/unknown_province_concern_builder.rb', line 18

def initialize(address, message_format = MessageFormat::Instructional)
  @address = address
  @message_format = message_format
end

Instance Attribute Details

#addressObject (readonly)

Returns the value of attribute address.



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

def address
  @address
end

#message_formatObject (readonly)

Returns the value of attribute message_format.



15
16
17
# File 'app/models/atlas_engine/address_validation/validators/full_address/unknown_province_concern_builder.rb', line 15

def message_format
  @message_format
end

Instance Method Details

#build(suggestion_ids = []) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/atlas_engine/address_validation/validators/full_address/unknown_province_concern_builder.rb', line 24

def build(suggestion_ids = [])
  message = country.field(key: :province).error(
    code: "unknown_for_city_and_zip_#{message_format.serialize}".to_sym,
    options: { city: address.city, zip: address.zip },
  ).to_s

  Concern.new(
    code: :province_inconsistent,
    field_names: [:province],
    message: message,
    type: T.must(Concern::TYPES[:error]),
    type_level: 1,
    suggestion_ids: suggestion_ids,
  )
end