summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-01-10 18:09:00 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-01-12 17:54:55 +0800
commita93ccf07107c1680b19c16c3365ee6a94f450811 (patch)
tree1ff5c7b22d472cd553efd73056a801e81934ead2
parent4f00a05152c105814f17a5f582d493435de96747 (diff)
downloadgitlab-ce-a93ccf07107c1680b19c16c3365ee6a94f450811.tar.gz
Properly cleaning up memoized values
-rw-r--r--app/models/concerns/resolvable_discussion.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/app/models/concerns/resolvable_discussion.rb b/app/models/concerns/resolvable_discussion.rb
index 6a2cb80b6d5..7c236369793 100644
--- a/app/models/concerns/resolvable_discussion.rb
+++ b/app/models/concerns/resolvable_discussion.rb
@@ -44,7 +44,9 @@ module ResolvableDiscussion
end
def first_note
- notes.first
+ strong_memoize(:first_note) do
+ notes.first
+ end
end
def first_note_to_resolve
@@ -102,8 +104,8 @@ module ResolvableDiscussion
# Set the notes array to the updated notes
@notes = notes_relation.fresh.to_a # rubocop:disable Gitlab/ModuleWithInstanceVariables
- self.class.memoized_values.each do |var|
- instance_variable_set(:"@#{var}", nil)
+ self.class.memoized_values.each do |name|
+ clear_memoization(name)
end
end
end