Sha256: e58d05de7bc2efdedda937f7341289b98fdeeb50f49a1f58d7dc3b7064e4e163

Contents?: true

Size: 820 Bytes

Versions: 7

Compression:

Stored size: 820 Bytes

Contents

module Mutant
  class Matcher

    # Matcher for specific namespace
    class Namespace < self
      include Concord::Public.new(:env, :expression)

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

        env.matchable_scopes.select do |scope|
          scope.each(&block) if match?(scope)
        end

        self
      end

    private

      # Test scope if name matches expression
      #
      # @param [Module, Class] scope
      #
      # @return [Boolean]
      #
      # @api private
      def match?(scope)
        expression.prefix?(scope.expression)
      end

    end # Namespace
  end # Matcher
end # Mutant

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mutant-0.8.7 lib/mutant/matcher/namespace.rb
mutant-0.8.6 lib/mutant/matcher/namespace.rb
mutant-0.8.5 lib/mutant/matcher/namespace.rb
mutant-0.8.4 lib/mutant/matcher/namespace.rb
mutant-0.8.3 lib/mutant/matcher/namespace.rb
mutant-0.8.2 lib/mutant/matcher/namespace.rb
mutant-0.8.1 lib/mutant/matcher/namespace.rb