Skip to content
代码片段 群组 项目
提交 b9d89463 编辑于 作者: Sean McGivern's avatar Sean McGivern
浏览文件

Don't use public_send in destroy_conditionally! helper

As we only override in two places, we could just ask for the value rather than
the method name.
上级 07a7801c
No related branches found
No related tags found
无相关合并请求
......@@ -130,7 +130,7 @@ class Branches < Grape::API
commit = user_project.repository.commit(branch.dereferenced_target)
destroy_conditionally!(commit, last_update_field: :authored_date) do
destroy_conditionally!(commit, last_updated: commit.authored_date) do
result = DeleteBranchService.new(user_project, current_user)
.execute(params[:branch])
......
......@@ -19,8 +19,10 @@ def check_unmodified_since!(last_modified)
end
end
def destroy_conditionally!(resource, last_update_field: :updated_at)
check_unmodified_since!(resource.public_send(last_update_field))
def destroy_conditionally!(resource, last_updated: nil)
last_updated ||= resource.updated_at
check_unmodified_since!(last_updated)
status 204
if block_given?
......
......@@ -70,7 +70,7 @@ class Tags < Grape::API
commit = user_project.repository.commit(tag.dereferenced_target)
destroy_conditionally!(commit, last_update_field: :authored_date) do
destroy_conditionally!(commit, last_updated: commit.authored_date) do
result = ::Tags::DestroyService.new(user_project, current_user)
.execute(params[:tag_name])
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册