Sha256: b525c08c0e83d3300cbacd05b3bd87b032111e140b7efae9f7f0bc6c4e4029cc

Contents?: true

Size: 822 Bytes

Versions: 3

Compression:

Stored size: 822 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 == 1
          return matchers.first
        end

        new(matchers)
      end

    end # Chain
  end # Matcher
end # Mutant

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mutant-0.5.22 lib/mutant/matcher/chain.rb
mutant-0.5.21 lib/mutant/matcher/chain.rb
mutant-0.5.20 lib/mutant/matcher/chain.rb