Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/cache/helpers.rb')
-rw-r--r--lib/gitlab/cache/helpers.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/gitlab/cache/helpers.rb b/lib/gitlab/cache/helpers.rb
index 024fa48c066..0fc0b1504af 100644
--- a/lib/gitlab/cache/helpers.rb
+++ b/lib/gitlab/cache/helpers.rb
@@ -45,7 +45,14 @@ module Gitlab
def contextual_cache_key(presenter, object, context)
return object.cache_key if context.nil?
- [presenter.class.name, object.cache_key, context.call(object)].flatten.join(":")
+ [presenter_class_name(presenter), object.cache_key, context.call(object)].flatten.join(":")
+ end
+
+ def presenter_class_name(presenter)
+ return presenter.class.name if presenter.is_a?(BaseSerializer)
+ return presenter.name if presenter.is_a?(Class) && presenter < Grape::Entity
+
+ raise ArgumentError, "presenter #{presenter} is not supported"
end
# Used for fetching or rendering a single object