Sha256: a423a2459f31e5313b2bcab8546f1b374b8929b8565f0b1f2f71279d2f52c181

Contents?: true

Size: 827 Bytes

Versions: 2

Compression:

Stored size: 827 Bytes

Contents

module Mutant
  class Matcher
    # A chain of matchers
    class Chain < self
      include Concord::Public.new(:matchers)

      # Enumerate subjects
      #
      # @return [Enumerator<Subject]
      #   if no block given
      #
      # @return [self]
      #   otherwise
      #
      # @api private
      #
      def each(&block)
        return to_enum unless block_given?

        matchers.each do |matcher|
          matcher.each(&block)
        end

        self
      end

      # Build matcher chain
      #
      # @param [Enumerable<Matcher>] matchers
      #
      # @return [Matcher]
      #
      # @api private
      #
      def self.build(matchers)
        if matchers.length.equal?(1)
          return matchers.first
        end

        new(matchers)
      end

    end # Chain
  end # Matcher
end # Mutant

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mutant-0.5.24 lib/mutant/matcher/chain.rb
mutant-0.5.23 lib/mutant/matcher/chain.rb