diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-21 18:21:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-21 18:21:10 +0300 |
commit | e33f87ac0fabaab468ce4b457996cc0f1b1bb648 (patch) | |
tree | 8bf0de72a9acac014cfdaddab7d463b208294af2 /lib/banzai | |
parent | 5baf990db20a75078684702782c24399ef9eb0fa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/pipeline.rb | 28 |
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 |