Class: Ci::BuildCancelService
- Inherits:
-
Object
- Object
- Ci::BuildCancelService
- Defined in:
- app/services/ci/build_cancel_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(build, user, force = false) ⇒ BuildCancelService
constructor
A new instance of BuildCancelService.
Constructor Details
#initialize(build, user, force = false) ⇒ BuildCancelService
Returns a new instance of BuildCancelService.
5 6 7 8 9 |
# File 'app/services/ci/build_cancel_service.rb', line 5 def initialize(build, user, force = false) @build = build @user = user @force = force end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/services/ci/build_cancel_service.rb', line 11 def execute return forbidden unless allowed? return unprocessable_entity unless build.cancelable? || (force && allowed_to_force?) if force build.force_cancel else build.cancel end ServiceResponse.success(payload: build) end |