Commit db0182e2 authored by Timothy Andrew's avatar Timothy Andrew

Implement third round of review comments from @DouweM.

Extract/mutate `params` in the `execute` method of the API services,
rather than in `initialize`.
parent 1051087a
...@@ -4,22 +4,16 @@ ...@@ -4,22 +4,16 @@
# lives in this service. # lives in this service.
module ProtectedBranches module ProtectedBranches
class ApiCreateService < BaseService class ApiCreateService < BaseService
def initialize(project, user, params)
@developers_can_merge = params.delete(:developers_can_merge)
@developers_can_push = params.delete(:developers_can_push)
super(project, user, params)
end
def execute def execute
push_access_level = push_access_level =
if @developers_can_push if params.delete(:developers_can_push)
Gitlab::Access::DEVELOPER Gitlab::Access::DEVELOPER
else else
Gitlab::Access::MASTER Gitlab::Access::MASTER
end end
merge_access_level = merge_access_level =
if @developers_can_merge if params.delete(:developers_can_merge)
Gitlab::Access::DEVELOPER Gitlab::Access::DEVELOPER
else else
Gitlab::Access::MASTER Gitlab::Access::MASTER
......
...@@ -4,13 +4,10 @@ ...@@ -4,13 +4,10 @@
# lives in this service. # lives in this service.
module ProtectedBranches module ProtectedBranches
class ApiUpdateService < BaseService class ApiUpdateService < BaseService
def initialize(project, user, params) def execute(protected_branch)
@developers_can_merge = params.delete(:developers_can_merge)
@developers_can_push = params.delete(:developers_can_push) @developers_can_push = params.delete(:developers_can_push)
super(project, user, params) @developers_can_merge = params.delete(:developers_can_merge)
end
def execute(protected_branch)
@protected_branch = protected_branch @protected_branch = protected_branch
protected_branch.transaction do protected_branch.transaction do
......
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