Cleanup namespace matcher
This commit is contained in:
parent
2dbf91940c
commit
84bfea0357
1 changed files with 5 additions and 25 deletions
|
@ -2,7 +2,9 @@ module Mutant
|
||||||
class Matcher
|
class Matcher
|
||||||
# Matcher for specific namespace
|
# Matcher for specific namespace
|
||||||
class Namespace < self
|
class Namespace < self
|
||||||
include Equalizer.new(:pattern)
|
include Concord.new(:namespace)
|
||||||
|
|
||||||
|
MATCHERS = [Matcher::Methods::Singleton, Matcher::Methods::Instance]
|
||||||
|
|
||||||
# Enumerate subjects
|
# Enumerate subjects
|
||||||
#
|
#
|
||||||
|
@ -24,30 +26,8 @@ module Mutant
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
# Return namespace
|
|
||||||
#
|
|
||||||
# @return [Class::Module]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
attr_reader :namespace
|
|
||||||
|
|
||||||
MATCHERS = [Matcher::Methods::Singleton, Matcher::Methods::Instance]
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# Initialize object space matcher
|
|
||||||
#
|
|
||||||
# @param [Class, Module] namespace
|
|
||||||
#
|
|
||||||
# @return [undefined]
|
|
||||||
#
|
|
||||||
# @api private
|
|
||||||
#
|
|
||||||
def initialize(namespace)
|
|
||||||
@namespace = namespace
|
|
||||||
end
|
|
||||||
|
|
||||||
# Return pattern
|
# Return pattern
|
||||||
#
|
#
|
||||||
# @return [Regexp]
|
# @return [Regexp]
|
||||||
|
@ -55,13 +35,13 @@ module Mutant
|
||||||
# @api private
|
# @api private
|
||||||
#
|
#
|
||||||
def pattern
|
def pattern
|
||||||
%r(\A#{Regexp.escape(namespace.name)}(?:::)?\z)
|
%r(\A#{Regexp.escape(namespace.name)}(?:::)?)
|
||||||
end
|
end
|
||||||
memoize :pattern
|
memoize :pattern
|
||||||
|
|
||||||
# Yield matchers for scope
|
# Yield matchers for scope
|
||||||
#
|
#
|
||||||
# @param [::Class,::Module] scope
|
# @param [Class,Module] scope
|
||||||
#
|
#
|
||||||
# @return [undefined]
|
# @return [undefined]
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue