mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 08:57:10 -06:00
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.
This commit is contained in:
parent
3f3d2ee2c0
commit
983fd04f4b
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user