Commit b9d89463 authored by 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.
parent 07a7801c
...@@ -130,7 +130,7 @@ module API ...@@ -130,7 +130,7 @@ module API
commit = user_project.repository.commit(branch.dereferenced_target) 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) result = DeleteBranchService.new(user_project, current_user)
.execute(params[:branch]) .execute(params[:branch])
......
...@@ -19,8 +19,10 @@ module API ...@@ -19,8 +19,10 @@ module API
end end
end end
def destroy_conditionally!(resource, last_update_field: :updated_at) def destroy_conditionally!(resource, last_updated: nil)
check_unmodified_since!(resource.public_send(last_update_field)) last_updated ||= resource.updated_at
check_unmodified_since!(last_updated)
status 204 status 204
if block_given? if block_given?
......
...@@ -70,7 +70,7 @@ module API ...@@ -70,7 +70,7 @@ module API
commit = user_project.repository.commit(tag.dereferenced_target) 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) result = ::Tags::DestroyService.new(user_project, current_user)
.execute(params[:tag_name]) .execute(params[:tag_name])
......
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