aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/values
diff options
context:
space:
mode:
authorChris LaRose <cjlarose@gmail.com>2017-11-22 09:12:08 -0800
committerAndrew White <pixeltrix@users.noreply.github.com>2017-11-22 17:12:08 +0000
commit078421bacba178eac6a8e607b16f3f4511c5d72f (patch)
treec8732cbdc32fd66191fa89ebab7ef9721aca0499 /activesupport/lib/active_support/values
parent858baa099b26f6b3e9eb8376d9c09559fe5cc599 (diff)
downloadrails-078421bacba178eac6a8e607b16f3f4511c5d72f.tar.gz
rails-078421bacba178eac6a8e607b16f3f4511c5d72f.tar.bz2
rails-078421bacba178eac6a8e607b16f3f4511c5d72f.zip
Make ActiveSupport::TimeZone.all independent of previous lookups (#31176)
Diffstat (limited to 'activesupport/lib/active_support/values')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index b294d99fe0..07e37f5dd2 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -256,6 +256,13 @@ module ActiveSupport
@country_zones[code] ||= load_country_zones(code)
end
+ def clear() #:nodoc:
+ @lazy_zones_map = Concurrent::Map.new
+ @country_zones = Concurrent::Map.new
+ @zones = nil
+ @zones_map = nil
+ end
+
private
def load_country_zones(code)
country = TZInfo::Country.get(code)
@@ -269,9 +276,8 @@ module ActiveSupport
end
def zones_map
- @zones_map ||= begin
- MAPPING.each_key { |place| self[place] } # load all the zones
- @lazy_zones_map
+ @zones_map ||= MAPPING.each_with_object({}) do |(name, _), zones|
+ zones[name] = self[name]
end
end
end