free_mutant/lib/mutant/predicate/matcher.rb
Markus Schirp e9931f6abe Slightly refactor CLI
* Backlists should "work" now.
* CLI (match expression) classifiers are not used as matchers anymore
2013-09-13 22:34:19 +02:00

36 lines
657 B
Ruby

module Mutant
class Predicate
# Return matcher
class Matcher < self
include Concord.new(:matcher)
# Test if subject matches
#
# @param [Subject] subject
#
# @return [true]
# if subject is handled by matcher
#
# @return [false]
# otherwise
#
def match?(subject)
subjects.include?(subject)
end
private
# Return subjects matched by matcher
#
# @return [Set<Subject>]
#
# @api private
#
def subjects
matcher.to_a.to_set
end
memoize :subjects
end # Matcher
end # Predicate
end # Mutant