summaryrefslogtreecommitdiff
path: root/lib/gitlab/markdown/combined_pipeline.rb
blob: 6b08a5e9f728cf182de467e812b3f558b5375000 (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
require 'gitlab/markdown'

module Gitlab
  module Markdown
    module CombinedPipeline
      def self.new(*pipelines)
        Class.new(Pipeline) do
          const_set :PIPELINES, pipelines

          def self.pipelines
            self::PIPELINES
          end

          def self.filters
            pipelines.flat_map(&:filters)
          end

          def self.transform_context(context)
            pipelines.reduce(context) do |context, pipeline|
              pipeline.transform_context(context)
            end
          end
        end
      end
    end
  end
end