Class: Ci::BuildCancelService

Inherits:
Object
  • Object
show all
Defined in:
app/services/ci/build_cancel_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(build, user) ⇒ BuildCancelService

Returns a new instance of BuildCancelService.


5
6
7
8
# File 'app/services/ci/build_cancel_service.rb', line 5

def initialize(build, user)
  @build = build
  @user = user
end

Instance Method Details

#executeObject


10
11
12
13
14
15
16
17
# File 'app/services/ci/build_cancel_service.rb', line 10

def execute
  return forbidden unless allowed?
  return unprocessable_entity unless build.cancelable?

  build.cancel

  ServiceResponse.success(payload: build)
end