Sha256: 9d9a79792659ed86bff21419432fa23a1e27b6c75ab9600f22c8aaf3dba8f903

Contents?: true

Size: 841 Bytes

Versions: 31

Compression:

Stored size: 841 Bytes

Contents

# encoding: utf-8

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

31 entries across 31 versions & 1 rubygems

Version Path
mutant-0.5.19 lib/mutant/matcher/chain.rb
mutant-0.5.18 lib/mutant/matcher/chain.rb
mutant-0.5.17 lib/mutant/matcher/chain.rb
mutant-0.5.16 lib/mutant/matcher/chain.rb
mutant-0.5.15 lib/mutant/matcher/chain.rb
mutant-0.5.14 lib/mutant/matcher/chain.rb
mutant-0.5.13 lib/mutant/matcher/chain.rb
mutant-0.5.12 lib/mutant/matcher/chain.rb
mutant-0.5.11 lib/mutant/matcher/chain.rb
mutant-0.5.10 lib/mutant/matcher/chain.rb
mutant-0.5.9 lib/mutant/matcher/chain.rb
mutant-0.5.8 lib/mutant/matcher/chain.rb
mutant-0.5.7 lib/mutant/matcher/chain.rb
mutant-0.5.6 lib/mutant/matcher/chain.rb
mutant-0.5.5 lib/mutant/matcher/chain.rb
mutant-0.5.4 lib/mutant/matcher/chain.rb
mutant-0.5.3 lib/mutant/matcher/chain.rb
mutant-0.5.2 lib/mutant/matcher/chain.rb
mutant-0.5.1 lib/mutant/matcher/chain.rb
mutant-0.5.0 lib/mutant/matcher/chain.rb