Class: AtlasEngine::AddressValidation::Validators::Predicates::Cache

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/models/atlas_engine/address_validation/validators/predicates/cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(address) ⇒ Cache

Returns a new instance of Cache.



12
13
14
15
# File 'app/models/atlas_engine/address_validation/validators/predicates/cache.rb', line 12

def initialize(address)
  @address = address
  @empty_region = Worldwide::Region.new(iso_code: "ZZ")
end

Instance Method Details

#countryObject



18
19
20
21
22
23
24
# File 'app/models/atlas_engine/address_validation/validators/predicates/cache.rb', line 18

def country
  if @address.country_code.present?
    @country ||= Worldwide.region(code: @address.country_code)
  else
    @empty_region
  end
end

#provinceObject



27
28
29
30
31
32
33
# File 'app/models/atlas_engine/address_validation/validators/predicates/cache.rb', line 27

def province
  if @address.province_code.present?
    @province ||= country.zone(code: @address.province_code)
  else
    @empty_region
  end
end