Sha256: 2316c924dfaebb29c3a0cbf9849d558a5bf4f733255b60ab20861891d775c6dd

Contents?: true

Size: 991 Bytes

Versions: 9

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

module Mutant
  class Matcher
    # Matcher expanding Mutant::Scope objects into method matches
    # at singleton or instance level
    #
    # If we *ever* get other subjects than methods, its likely the place
    # to hook in custom matchers. In that case the scope matchers to expand
    # should be passed as arguments to the constructor.
    class Scope < self
      include Concord.new(:scope)

      MATCHERS = [
        Matcher::Methods::Singleton,
        Matcher::Methods::Instance
      ].freeze

      private_constant(*constants(false))

      # Matched subjects
      #
      # @param [Env] env
      #
      # @return [Enumerable<Subject>]
      def call(env)
        Chain.new(effective_matchers).call(env)
      end

    private

      # Effective matchers
      #
      # @return [Enumerable<Matcher>]
      def effective_matchers
        MATCHERS.map { |matcher| matcher.new(scope) }
      end

    end # Scope
  end # Matcher
end # Mutant

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mutant-0.9.8 lib/mutant/matcher/scope.rb
mutant-0.9.7 lib/mutant/matcher/scope.rb
mutant-0.9.6 lib/mutant/matcher/scope.rb
mutant-0.9.5 lib/mutant/matcher/scope.rb
mutant-0.9.4 lib/mutant/matcher/scope.rb
mutant-0.9.3 lib/mutant/matcher/scope.rb
mutant-0.9.2 lib/mutant/matcher/scope.rb
mutant-0.9.1 lib/mutant/matcher/scope.rb
mutant-0.9.0 lib/mutant/matcher/scope.rb