combined_pipeline.rb 600 Bytes
Newer Older
1 2
# frozen_string_literal: true

3 4
module Banzai
  module Pipeline
5 6
    module CombinedPipeline
      def self.new(*pipelines)
7
        Class.new(BasePipeline) do
8 9
          const_set :PIPELINES, pipelines

10 11 12 13
          def self.pipelines
            self::PIPELINES
          end

14
          def self.filters
15
            FilterArray.new(pipelines.flat_map(&:filters))
16 17 18
          end

          def self.transform_context(context)
19 20 21
            pipelines.reduce(context) do |context, pipeline|
              pipeline.transform_context(context)
            end
22 23 24 25 26 27
          end
        end
      end
    end
  end
end