2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
module Banzai
|
|
|
|
module Pipeline
|
2020-04-22 19:07:51 +05:30
|
|
|
# Resolve a pipeline by name
|
|
|
|
#
|
|
|
|
# name - nil, Class or Symbol. The name to be resolved.
|
|
|
|
#
|
|
|
|
# Examples:
|
|
|
|
# Pipeline[nil] # => Banzai::Pipeline::FullPipeline
|
|
|
|
# Pipeline[:label] # => Banzai::Pipeline::LabelPipeline
|
2020-05-24 23:13:21 +05:30
|
|
|
# Pipeline[StatusPage::Pipeline::PostProcessPipeline] # => StatusPage::Pipeline::PostProcessPipeline
|
2020-04-22 19:07:51 +05:30
|
|
|
#
|
|
|
|
# Pipeline['label'] # => raises ArgumentError - unsupport type
|
|
|
|
# Pipeline[Project] # => raises ArgumentError - not a subclass of BasePipeline
|
|
|
|
#
|
|
|
|
# Returns a pipeline class which is a subclass of Banzai::Pipeline::BasePipeline.
|
2015-12-23 02:04:40 +05:30
|
|
|
def self.[](name)
|
2020-04-22 19:07:51 +05:30
|
|
|
name ||= FullPipeline
|
|
|
|
|
|
|
|
pipeline = case name
|
|
|
|
when Class
|
|
|
|
name
|
|
|
|
when Symbol
|
|
|
|
const_get("#{name.to_s.camelize}Pipeline", false)
|
|
|
|
end
|
|
|
|
|
|
|
|
return pipeline if pipeline && pipeline < BasePipeline
|
|
|
|
|
|
|
|
raise ArgumentError,
|
|
|
|
"unsupported pipeline name #{name.inspect} (#{name.class})"
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|