From 983fd04f4b208b7de37227abf8664497b16c7ef2 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Fri, 27 Oct 2023 13:35:33 +0100 Subject: [PATCH] FIX: Memoization in EmberCli ruby helper class (#24139) Previously we were memoizing based on `defined?`, but the `clear_cache!` method was doing `@blah = nil`. That meant that after the cache was cleared, future calls to the memoized method would return `nil` instead of triggering a recalculation. --- lib/ember_cli.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ember_cli.rb b/lib/ember_cli.rb index a71f3609f00..b2e7607c9ce 100644 --- a/lib/ember_cli.rb +++ b/lib/ember_cli.rb @@ -6,11 +6,11 @@ module EmberCli end def self.assets - @@assets ||= Dir.glob("**/*.{js,map,txt}", base: "#{dist_dir}/assets") + @assets ||= Dir.glob("**/*.{js,map,txt}", base: "#{dist_dir}/assets") end def self.script_chunks - return @@chunk_infos if defined?(@@chunk_infos) + return @chunk_infos if @chunk_infos chunk_infos = {} @@ -24,7 +24,7 @@ module EmberCli index_html = File.read("#{dist_dir}/index.html") chunk_infos.merge! parse_chunks_from_html(index_html) - @@chunk_infos = chunk_infos if Rails.env.production? + @chunk_infos = chunk_infos if Rails.env.production? chunk_infos rescue Errno::ENOENT {} @@ -80,7 +80,7 @@ module EmberCli end def self.clear_cache! - @@chunk_infos = nil - @@assets = nil + @chunk_infos = nil + @assets = nil end end