summaryrefslogtreecommitdiff
path: root/lib/banzai
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-20 18:38:24 +0000
commit983a0bba5d2a042c4a3bbb22432ec192c7501d82 (patch)
treeb153cd387c14ba23bd5a07514c7c01fddf6a78a0 /lib/banzai
parenta2bddee2cdb38673df0e004d5b32d9f77797de64 (diff)
downloadgitlab-ce-983a0bba5d2a042c4a3bbb22432ec192c7501d82.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'lib/banzai')
-rw-r--r--lib/banzai/pipeline.rb28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/banzai/pipeline.rb b/lib/banzai/pipeline.rb
index 497d3f27542..8fdbc044861 100644
--- a/lib/banzai/pipeline.rb
+++ b/lib/banzai/pipeline.rb
@@ -2,9 +2,33 @@
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 ||= :full
- const_get("#{name.to_s.camelize}Pipeline", false)
+ 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