Class: AtlasEngine::AddressValidation::Validators::FullAddress::UnknownAddressConcernBuilder

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Includes:
ConcernFormatter
Defined in:
app/models/atlas_engine/address_validation/validators/full_address/unknown_address_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) ⇒ UnknownAddressConcernBuilder

Returns a new instance of UnknownAddressConcernBuilder.



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

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.



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

def address
  @address
end

#message_formatObject (readonly)

Returns the value of attribute message_format.



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

def message_format
  @message_format
end

Instance Method Details

#build(suggestion_ids = []) ⇒ Object



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_address_concern_builder.rb', line 25

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

  Concern.new(
    code: :address_unknown,
    message: message,
    type: T.must(Concern::TYPES[:warning]),
    type_level: 1,
    suggestion_ids: suggestion_ids,
    field_names: [field],
  )
end