Module: Pipeline::ApiMethods

Included in:
Pipeline
Defined in:
lib/pipeline/api_methods.rb

Instance Method Summary collapse

Instance Method Details

#cancel(id) ⇒ Object



18
19
20
21
22
23
# File 'lib/pipeline/api_methods.rb', line 18

def cancel(id)
  pipeline = Base.find(id)
  pipeline.cancel
rescue ActiveRecord::RecordNotFound
  raise InvalidPipelineError.new("Invalid pipeline")
end

#resume(id) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/pipeline/api_methods.rb', line 10

def resume(id)
  pipeline = Base.find(id)
  raise InvalidStatusError.new(pipeline.status) unless pipeline.ok_to_resume?
  Delayed::Job.enqueue(pipeline)
rescue ActiveRecord::RecordNotFound
  raise InvalidPipelineError.new("Invalid pipeline")
end

#start(pipeline) ⇒ Object



3
4
5
6
7
8
# File 'lib/pipeline/api_methods.rb', line 3

def start(pipeline)
  raise InvalidPipelineError.new("Invalid pipeline") unless pipeline.is_a?(Pipeline::Base)
  pipeline.save! if pipeline.new_record?
  Delayed::Job.enqueue(pipeline)
  pipeline.id
end