Cleanup namespace matcher

This commit is contained in:
Markus Schirp 2013-04-19 23:36:49 +02:00
parent 2dbf91940c
commit 84bfea0357

View file

@ -2,7 +2,9 @@ module Mutant
class Matcher
# Matcher for specific namespace
class Namespace < self
include Equalizer.new(:pattern)
include Concord.new(:namespace)
MATCHERS = [Matcher::Methods::Singleton, Matcher::Methods::Instance]
# Enumerate subjects
#
@ -24,30 +26,8 @@ module Mutant
self
end
# Return namespace
#
# @return [Class::Module]
#
# @api private
#
attr_reader :namespace
MATCHERS = [Matcher::Methods::Singleton, Matcher::Methods::Instance]
private
# Initialize object space matcher
#
# @param [Class, Module] namespace
#
# @return [undefined]
#
# @api private
#
def initialize(namespace)
@namespace = namespace
end
# Return pattern
#
# @return [Regexp]
@ -55,13 +35,13 @@ module Mutant
# @api private
#
def pattern
%r(\A#{Regexp.escape(namespace.name)}(?:::)?\z)
%r(\A#{Regexp.escape(namespace.name)}(?:::)?)
end
memoize :pattern
# Yield matchers for scope
#
# @param [::Class,::Module] scope
# @param [Class,Module] scope
#
# @return [undefined]
#