class Employer::Pipeline
Attributes
logger[R]
Public Class Methods
new(logger)
click to toggle source
# File lib/employer/pipeline.rb, line 7 def initialize(logger) @logger = logger end
Public Instance Methods
backend()
click to toggle source
# File lib/employer/pipeline.rb, line 15 def backend @backend end
backend=(backend)
click to toggle source
# File lib/employer/pipeline.rb, line 11 def backend=(backend) @backend = backend end
clear()
click to toggle source
# File lib/employer/pipeline.rb, line 33 def clear raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Clearing pipeline of all jobs!") backend.clear end
complete(job)
click to toggle source
# File lib/employer/pipeline.rb, line 39 def complete(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Marking job #{job.id} as complete") backend.complete(job) end
dequeue()
click to toggle source
# File lib/employer/pipeline.rb, line 25 def dequeue raise Employer::Errors::PipelineBackendRequired if backend.nil? if serialized_job = backend.dequeue job_class = constantize(serialized_job[:class]) job_class.deserialize(serialized_job) end end
enqueue(job)
click to toggle source
# File lib/employer/pipeline.rb, line 19 def enqueue(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? serialized_job = job.serialize backend.enqueue(serialized_job) end
fail(job)
click to toggle source
# File lib/employer/pipeline.rb, line 51 def fail(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Marking job #{job.id} as failed") backend.fail(job) end
reset(job)
click to toggle source
# File lib/employer/pipeline.rb, line 45 def reset(job) raise Employer::Errors::PipelineBackendRequired if backend.nil? logger.info("Resetting job #{job.id}") backend.reset(job) end
Private Instance Methods
constantize(camel_cased_word)
click to toggle source
# File lib/employer/pipeline.rb, line 59 def constantize(camel_cased_word) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? constant = Object names.each do |name| constant = constant.const_defined?(name, false) ? constant.const_get(name) : constant.const_missing(name) end constant end