2018-10-06 19:10:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-15 09:51:16 -05:00
|
|
|
module Banzai
|
|
|
|
module Pipeline
|
2020-04-21 11:21:10 -04:00
|
|
|
# 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-05 17:09:42 -04:00
|
|
|
# Pipeline[StatusPage::Pipeline::PostProcessPipeline] # => StatusPage::Pipeline::PostProcessPipeline
|
2020-04-21 11:21:10 -04:00
|
|
|
#
|
|
|
|
# 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-15 09:51:16 -05:00
|
|
|
def self.[](name)
|
2020-04-21 11:21:10 -04:00
|
|
|
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-15 09:51:16 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|