Sha256: d22193f9b20e80de6d2aa9507753743cbddba7d78ea8e234026389b338a49b83

Contents?: true

Size: 955 Bytes

Versions: 59

Compression:

Stored size: 955 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,
        Matcher::Methods::Metaclass
      ].freeze

      private_constant(*constants(false))

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

    private

      def effective_matchers
        MATCHERS.map { |matcher| matcher.new(scope) }
      end

    end # Scope
  end # Matcher
end # Mutant

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
mutant-0.11.18 lib/mutant/matcher/scope.rb
mutant-0.11.17 lib/mutant/matcher/scope.rb
mutant-0.11.16 lib/mutant/matcher/scope.rb
mutant-0.11.15 lib/mutant/matcher/scope.rb
mutant-0.11.14 lib/mutant/matcher/scope.rb
mutant-0.11.13 lib/mutant/matcher/scope.rb
mutant-0.11.12 lib/mutant/matcher/scope.rb
mutant-0.11.11 lib/mutant/matcher/scope.rb
mutant-0.11.10 lib/mutant/matcher/scope.rb
mutant-0.11.9 lib/mutant/matcher/scope.rb
mutant-0.11.8 lib/mutant/matcher/scope.rb
mutant-0.11.7 lib/mutant/matcher/scope.rb
mutant-0.11.6 lib/mutant/matcher/scope.rb
mutant-0.11.5 lib/mutant/matcher/scope.rb
mutant-0.11.4 lib/mutant/matcher/scope.rb
mutant-0.11.3 lib/mutant/matcher/scope.rb
mutant-0.11.2 lib/mutant/matcher/scope.rb
mutant-0.11.1 lib/mutant/matcher/scope.rb
mutant-0.11.0 lib/mutant/matcher/scope.rb
mutant-0.10.35 lib/mutant/matcher/scope.rb