2012-07-23 16:54:35 -04:00
|
|
|
module Mutant
|
2013-01-21 14:08:30 -05:00
|
|
|
# Abstract matcher to find subjects to mutate
|
2012-07-23 16:54:35 -04:00
|
|
|
class Matcher
|
2012-11-26 05:30:00 -05:00
|
|
|
include Adamantium::Flat, Enumerable, AbstractType
|
2012-07-23 16:54:35 -04:00
|
|
|
|
2013-01-21 16:56:52 -05:00
|
|
|
# Enumerate subjects
|
|
|
|
#
|
|
|
|
# @param [Object] input
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
# if block given
|
|
|
|
#
|
2013-07-04 18:54:50 -04:00
|
|
|
# @return [Enumerable<Subject>]
|
2013-09-07 13:42:07 -04:00
|
|
|
# otherwise
|
2013-01-21 16:56:52 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-06-27 16:18:07 -04:00
|
|
|
def self.each(cache, input, &block)
|
|
|
|
return to_enum(__method__, cache, input) unless block_given?
|
2013-01-21 16:56:52 -05:00
|
|
|
|
2013-07-04 18:54:50 -04:00
|
|
|
build(cache, input).each(&block)
|
2013-01-21 16:56:52 -05:00
|
|
|
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2013-07-04 18:54:50 -04:00
|
|
|
# Default matcher build implementation
|
|
|
|
#
|
|
|
|
# @param [Cache] cache
|
|
|
|
# @param [Object] input
|
|
|
|
#
|
|
|
|
# @return [undefined]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.build(*arguments)
|
|
|
|
new(*arguments)
|
|
|
|
end
|
|
|
|
|
2012-08-01 12:34:03 -04:00
|
|
|
# Enumerate subjects
|
2012-07-23 16:54:35 -04:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-01-21 14:08:30 -05:00
|
|
|
# @return [self]
|
|
|
|
# if block given
|
|
|
|
#
|
|
|
|
# @return [Enumerabe<Subject>]
|
|
|
|
# otherwise
|
2012-07-23 19:41:08 -04:00
|
|
|
#
|
2012-08-02 19:28:15 -04:00
|
|
|
abstract_method :each
|
2012-07-26 13:25:23 -04:00
|
|
|
|
2012-08-15 22:10:54 -04:00
|
|
|
# Return identification
|
|
|
|
#
|
|
|
|
# @return [String
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
abstract_method :identification
|
2013-06-14 14:54:02 -04:00
|
|
|
|
|
|
|
end # Matcher
|
|
|
|
end # Mutant
|