diff options
author | Ciro Santilli <ciro.santilli@gmail.com> | 2014-09-21 10:29:52 +0200 |
---|---|---|
committer | Ciro Santilli <ciro.santilli@gmail.com> | 2014-09-21 11:43:05 +0200 |
commit | ad47993ac46cef672600f2384ee5fa2e661ec8be (patch) | |
tree | 07769b4efeb4c18762b3ed0e705179a5423926c1 /app/services/create_branch_service.rb | |
parent | fda61a047ffb9b04bc4dd38e897088fde17fb3c1 (diff) | |
download | gitlab-ce-ad47993ac46cef672600f2384ee5fa2e661ec8be.tar.gz |
Factor error and success methods from services.
Diffstat (limited to 'app/services/create_branch_service.rb')
-rw-r--r-- | app/services/create_branch_service.rb | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb index 79b8239602e..901f67bafb3 100644 --- a/app/services/create_branch_service.rb +++ b/app/services/create_branch_service.rb @@ -1,5 +1,7 @@ -class CreateBranchService - def execute(project, branch_name, ref, current_user) +require_relative 'base_service' + +class CreateBranchService < BaseService + def execute(branch_name, ref) valid_branch = Gitlab::GitRefValidator.validate(branch_name) if valid_branch == false return error('Branch name invalid') @@ -22,17 +24,9 @@ class CreateBranchService end end - def error(message) - { - message: message, - status: :error - } - end - def success(branch) - { - branch: branch, - status: :success - } + out = super() + out[:branch] = branch + out end end |