Sha256: c3b7a5a526f5bf72fdcd5302a2c9047b1e9f94e5f2dc22d0e6a5b6c844b8629b

Contents?: true

Size: 913 Bytes

Versions: 5

Compression:

Stored size: 913 Bytes

Contents

# typed: true
# frozen_string_literal: true

require 'sorbet-runtime'

module Frontman
  module Process
    class Chain
      extend T::Sig

      sig do
        params(
          processors: T::Array[Frontman::Process::Processor]
        ).returns(T.self_type)
      end
      def initialize(processors = [])
        @processors = []

        add_processors(processors)
      end

      sig do
        params(
          processors: T.any(
            Frontman::Process::Processor,
            T::Array[Frontman::Process::Processor]
          )
        ).returns(T.self_type)
      end
      def add_processors(processors)
        @processors.push(*Array(processors))
        self
      end

      sig { params(arguments: T.untyped).returns(T::Array[T.untyped]) }
      def process(*arguments)
        @processors.map do |processor|
          processor.process(*arguments)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
frontman-ssg-0.1.1 lib/frontman/process/chain.rb
frontman-ssg-0.1.0 lib/frontman/process/chain.rb
frontman-ssg-0.0.4 lib/frontman/process/chain.rb
frontman-ssg-0.0.3 lib/frontman/process/chain.rb
frontman-ssg-0.0.2 lib/frontman/process/chain.rb