summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-07-18 18:04:20 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-07-18 18:04:20 +0800
commit3922b803290ecccdb232c2c150ee249ba2b57c97 (patch)
treea05eb6d68525dcafb81be08c266e7b8c68dc9de1
parentffc5b29bd0f02676bdc05ec6185d115d6705cd8f (diff)
downloadgitlab-ce-3922b803290ecccdb232c2c150ee249ba2b57c97.tar.gz
Rename the methods to make it fit with current name
-rw-r--r--app/models/commit.rb2
-rw-r--r--lib/gitlab/cache/request_cache.rb18
-rw-r--r--lib/gitlab/user_access.rb10
-rw-r--r--spec/lib/gitlab/cache/request_cache_spec.rb10
4 files changed, 20 insertions, 20 deletions
diff --git a/app/models/commit.rb b/app/models/commit.rb
index 66c6ae4dacf..50790a710bb 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -172,7 +172,7 @@ class Commit
def author
User.find_by_any_email(author_email.downcase)
end
- request_store_wrap(:author) { author_email.downcase }
+ request_cache(:author) { author_email.downcase }
def committer
@committer ||= User.find_by_any_email(committer_email.downcase)
diff --git a/lib/gitlab/cache/request_cache.rb b/lib/gitlab/cache/request_cache.rb
index b012c876560..f1a04affd38 100644
--- a/lib/gitlab/cache/request_cache.rb
+++ b/lib/gitlab/cache/request_cache.rb
@@ -10,11 +10,11 @@ module Gitlab
# class UserAccess
# extend Gitlab::Cache::RequestCache
#
- # request_store_wrap_key do
+ # request_cache_key do
# [user&.id, project&.id]
# end
#
- # request_store_wrap def can_push_to_branch?(ref)
+ # request_cache def can_push_to_branch?(ref)
# # ...
# end
# end
@@ -31,7 +31,7 @@ module Gitlab
# def author
# User.find_by_any_email(author_email.downcase)
# end
- # request_store_wrap(:author) { author_email.downcase }
+ # request_cache(:author) { author_email.downcase }
# end
#
# So that we could have different strategies for different methods
@@ -45,15 +45,15 @@ module Gitlab
klass.prepend(extension)
end
- def request_store_wrap_key(&block)
+ def request_cache_key(&block)
if block_given?
- @request_store_wrap_key = block
+ @request_cache_key = block
else
- @request_store_wrap_key
+ @request_cache_key
end
end
- def request_store_wrap(method_name, &method_key_block)
+ def request_cache(method_name, &method_key_block)
const_get(:RequestCacheExtension).module_eval do
cache_key_method_name = "#{method_name}_cache_key"
@@ -77,8 +77,8 @@ module Gitlab
define_method(cache_key_method_name) do |args|
klass = self.class
- instance_key = instance_exec(&klass.request_store_wrap_key) if
- klass.request_store_wrap_key
+ instance_key = instance_exec(&klass.request_cache_key) if
+ klass.request_cache_key
method_key = instance_exec(&method_key_block) if method_key_block
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index a30dfe0f6bf..8e91ee7287c 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -2,7 +2,7 @@ module Gitlab
class UserAccess
extend Gitlab::Cache::RequestCache
- request_store_wrap_key do
+ request_cache_key do
[user&.id, project&.id]
end
@@ -34,7 +34,7 @@ module Gitlab
true
end
- request_store_wrap def can_create_tag?(ref)
+ request_cache def can_create_tag?(ref)
return false unless can_access_git?
if ProtectedTag.protected?(project, ref)
@@ -44,7 +44,7 @@ module Gitlab
end
end
- request_store_wrap def can_delete_branch?(ref)
+ request_cache def can_delete_branch?(ref)
return false unless can_access_git?
if ProtectedBranch.protected?(project, ref)
@@ -54,7 +54,7 @@ module Gitlab
end
end
- request_store_wrap def can_push_to_branch?(ref)
+ request_cache def can_push_to_branch?(ref)
return false unless can_access_git?
if ProtectedBranch.protected?(project, ref)
@@ -66,7 +66,7 @@ module Gitlab
end
end
- request_store_wrap def can_merge_to_branch?(ref)
+ request_cache def can_merge_to_branch?(ref)
return false unless can_access_git?
if ProtectedBranch.protected?(project, ref)
diff --git a/spec/lib/gitlab/cache/request_cache_spec.rb b/spec/lib/gitlab/cache/request_cache_spec.rb
index 62f914cf121..654686dc5d6 100644
--- a/spec/lib/gitlab/cache/request_cache_spec.rb
+++ b/spec/lib/gitlab/cache/request_cache_spec.rb
@@ -18,18 +18,18 @@ describe Gitlab::Cache::RequestCache, :request_store do
self.extra = nil
end
- request_store_wrap def compute(arg)
+ request_cache def compute(arg)
result << arg
end
- request_store_wrap def repute(arg)
+ request_cache def repute(arg)
result << arg
end
def dispute(arg)
result << arg
end
- request_store_wrap(:dispute) { extra }
+ request_cache(:dispute) { extra }
end
end
@@ -80,9 +80,9 @@ describe Gitlab::Cache::RequestCache, :request_store do
expect(algorithm.result).to eq(result)
end
- context 'when request_store_wrap_key is provided' do
+ context 'when request_cache_key is provided' do
before do
- klass.request_store_wrap_key do
+ klass.request_cache_key do
[id, name]
end
end