1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
module Sources
# Support code to allow updating subdivision data from the Unicode CLDR repository
module Local
# Loader for locally-cached data, to allow merging Unicode CLDR data with existing local data
class CachedLoader
attr_reader :klass
def initialize(klass)
@klass = klass
@loaded_countries = {}
end
def from_cache(country_code)
@loaded_countries[country_code]
end
def load(country_code)
if (data = from_cache(country_code))
data
else
@loaded_countries[country_code] = klass.load(country_code)
end
end
def save(country_code, data)
klass.new(country_code).save(data)
end
end
end
end
|