Commit 3922b803 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Rename the methods to make it fit with current name

parent ffc5b29b
...@@ -172,7 +172,7 @@ class Commit ...@@ -172,7 +172,7 @@ class Commit
def author def author
User.find_by_any_email(author_email.downcase) User.find_by_any_email(author_email.downcase)
end end
request_store_wrap(:author) { author_email.downcase } request_cache(:author) { author_email.downcase }
def committer def committer
@committer ||= User.find_by_any_email(committer_email.downcase) @committer ||= User.find_by_any_email(committer_email.downcase)
......
...@@ -10,11 +10,11 @@ module Gitlab ...@@ -10,11 +10,11 @@ module Gitlab
# class UserAccess # class UserAccess
# extend Gitlab::Cache::RequestCache # extend Gitlab::Cache::RequestCache
# #
# request_store_wrap_key do # request_cache_key do
# [user&.id, project&.id] # [user&.id, project&.id]
# end # end
# #
# request_store_wrap def can_push_to_branch?(ref) # request_cache def can_push_to_branch?(ref)
# # ... # # ...
# end # end
# end # end
...@@ -31,7 +31,7 @@ module Gitlab ...@@ -31,7 +31,7 @@ module Gitlab
# def author # def author
# User.find_by_any_email(author_email.downcase) # User.find_by_any_email(author_email.downcase)
# end # end
# request_store_wrap(:author) { author_email.downcase } # request_cache(:author) { author_email.downcase }
# end # end
# #
# So that we could have different strategies for different methods # So that we could have different strategies for different methods
...@@ -45,15 +45,15 @@ module Gitlab ...@@ -45,15 +45,15 @@ module Gitlab
klass.prepend(extension) klass.prepend(extension)
end end
def request_store_wrap_key(&block) def request_cache_key(&block)
if block_given? if block_given?
@request_store_wrap_key = block @request_cache_key = block
else else
@request_store_wrap_key @request_cache_key
end end
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 const_get(:RequestCacheExtension).module_eval do
cache_key_method_name = "#{method_name}_cache_key" cache_key_method_name = "#{method_name}_cache_key"
...@@ -77,8 +77,8 @@ module Gitlab ...@@ -77,8 +77,8 @@ module Gitlab
define_method(cache_key_method_name) do |args| define_method(cache_key_method_name) do |args|
klass = self.class klass = self.class
instance_key = instance_exec(&klass.request_store_wrap_key) if instance_key = instance_exec(&klass.request_cache_key) if
klass.request_store_wrap_key klass.request_cache_key
method_key = instance_exec(&method_key_block) if method_key_block method_key = instance_exec(&method_key_block) if method_key_block
......
...@@ -2,7 +2,7 @@ module Gitlab ...@@ -2,7 +2,7 @@ module Gitlab
class UserAccess class UserAccess
extend Gitlab::Cache::RequestCache extend Gitlab::Cache::RequestCache
request_store_wrap_key do request_cache_key do
[user&.id, project&.id] [user&.id, project&.id]
end end
...@@ -34,7 +34,7 @@ module Gitlab ...@@ -34,7 +34,7 @@ module Gitlab
true true
end end
request_store_wrap def can_create_tag?(ref) request_cache def can_create_tag?(ref)
return false unless can_access_git? return false unless can_access_git?
if ProtectedTag.protected?(project, ref) if ProtectedTag.protected?(project, ref)
...@@ -44,7 +44,7 @@ module Gitlab ...@@ -44,7 +44,7 @@ module Gitlab
end end
end end
request_store_wrap def can_delete_branch?(ref) request_cache def can_delete_branch?(ref)
return false unless can_access_git? return false unless can_access_git?
if ProtectedBranch.protected?(project, ref) if ProtectedBranch.protected?(project, ref)
...@@ -54,7 +54,7 @@ module Gitlab ...@@ -54,7 +54,7 @@ module Gitlab
end end
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? return false unless can_access_git?
if ProtectedBranch.protected?(project, ref) if ProtectedBranch.protected?(project, ref)
...@@ -66,7 +66,7 @@ module Gitlab ...@@ -66,7 +66,7 @@ module Gitlab
end end
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? return false unless can_access_git?
if ProtectedBranch.protected?(project, ref) if ProtectedBranch.protected?(project, ref)
......
...@@ -18,18 +18,18 @@ describe Gitlab::Cache::RequestCache, :request_store do ...@@ -18,18 +18,18 @@ describe Gitlab::Cache::RequestCache, :request_store do
self.extra = nil self.extra = nil
end end
request_store_wrap def compute(arg) request_cache def compute(arg)
result << arg result << arg
end end
request_store_wrap def repute(arg) request_cache def repute(arg)
result << arg result << arg
end end
def dispute(arg) def dispute(arg)
result << arg result << arg
end end
request_store_wrap(:dispute) { extra } request_cache(:dispute) { extra }
end end
end end
...@@ -80,9 +80,9 @@ describe Gitlab::Cache::RequestCache, :request_store do ...@@ -80,9 +80,9 @@ describe Gitlab::Cache::RequestCache, :request_store do
expect(algorithm.result).to eq(result) expect(algorithm.result).to eq(result)
end end
context 'when request_store_wrap_key is provided' do context 'when request_cache_key is provided' do
before do before do
klass.request_store_wrap_key do klass.request_cache_key do
[id, name] [id, name]
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment