From 78e4d88c7071c633ee1eb68f49b90719aa198eaa Mon Sep 17 00:00:00 2001 From: Leigh Caplan Date: Mon, 28 Jun 2010 15:38:16 -0700 Subject: [PATCH] Rewrite the clause to pluck the existing value from zones_map before performing a lookup. [#4942 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- activesupport/lib/active_support/values/time_zone.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 0c39c764cb..ad9ea2ace2 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -387,8 +387,10 @@ def zones_map def [](arg) case arg when String - if tz = lookup(arg) - zones_map[arg] ||= tz + if tz = zones_map[arg] + tz + elsif tz = lookup(arg) + zones_map[arg] = tz end when Numeric, ActiveSupport::Duration arg *= 3600 if arg.abs <= 13 -- GitLab