blob: 8fdbc0448617015c44d934d52e5b278098a63f36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# frozen_string_literal: true
module Banzai
module Pipeline
# 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
# Pipeline[StatusPage::PostProcessPipeline] # => StatusPage::PostProcessPipeline
#
# 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.
def self.[](name)
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})"
end
end
end
|