summaryrefslogtreecommitdiff
path: root/lib/banzai/pipeline/combined_pipeline.rb
blob: 9485199132ecd83bdfb961164a5cb6eb0b2c4f1c (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
module Banzai
  module Pipeline
    module CombinedPipeline
      def self.new(*pipelines)
        Class.new(BasePipeline) 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