Class: AtlasEngine::ValidationTranscriber::AddressParserFactory

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/lib/atlas_engine/validation_transcriber/address_parser_factory.rb

Class Method Summary collapse

Class Method Details

.create(address:, locale: nil) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
18
19
20
21
22
23
# File 'app/lib/atlas_engine/validation_transcriber/address_parser_factory.rb', line 13

def create(address:, locale: nil)
  raise ArgumentError, "country_code cannot be nil" if address.country_code.nil?

  profile = CountryProfile.for(T.must(address.country_code), locale)

  if locale.nil? && profile.validation.multi_locale?
    raise ArgumentError, "#{address.country_code} is a multi-locale country and requires a locale"
  end

  profile.validation.address_parser.new(address: address)
end