Class: Ci::Runners::UpdateRunnerService

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ UpdateRunnerService

Returns a new instance of UpdateRunnerService.



8
9
10
# File 'app/services/ci/runners/update_runner_service.rb', line 8

def initialize(runner)
  @runner = runner
end

Instance Attribute Details

#runnerObject (readonly)

Returns the value of attribute runner.



6
7
8
# File 'app/services/ci/runners/update_runner_service.rb', line 6

def runner
  @runner
end

Instance Method Details

#execute(params) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'app/services/ci/runners/update_runner_service.rb', line 12

def execute(params)
  params[:active] = !params.delete(:paused) if params.include?(:paused)

  if runner.update(params)
    runner.tick_runner_queue
    ServiceResponse.success
  else
    ServiceResponse.error(message: runner.errors.full_messages)
  end
end