2013-01-13 16:29:07 -05:00
|
|
|
module Mutant
|
|
|
|
class Strategy
|
|
|
|
module MethodExpansion
|
|
|
|
|
|
|
|
# Run method name expansion
|
|
|
|
#
|
|
|
|
# @param [Symbol] name
|
|
|
|
#
|
|
|
|
# @return [Symbol]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.run(name)
|
|
|
|
name = map(name) || expand(name)
|
|
|
|
end
|
|
|
|
|
|
|
|
# Return mapped name
|
|
|
|
#
|
|
|
|
# @param [Symbol] name
|
|
|
|
#
|
|
|
|
# @return [Symbol]
|
|
|
|
# if name was mapped
|
|
|
|
#
|
|
|
|
# @return [nil]
|
|
|
|
# otherwise
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.map(name)
|
|
|
|
OPERATOR_EXPANSIONS[name]
|
|
|
|
end
|
|
|
|
private_class_method :map
|
|
|
|
|
2013-02-22 14:46:22 -05:00
|
|
|
REGEXP = /#{Regexp.union(*METHOD_POSTFIX_EXPANSIONS.keys)}\z/.freeze
|
|
|
|
|
2013-01-13 16:29:07 -05:00
|
|
|
# Return expanded name
|
|
|
|
#
|
|
|
|
# @param [Symbol] name
|
|
|
|
#
|
|
|
|
# @return [Symbol]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def self.expand(name)
|
2013-02-22 17:33:54 -05:00
|
|
|
name.to_s.sub(REGEXP, METHOD_POSTFIX_EXPANSIONS).to_sym
|
2013-01-13 16:29:07 -05:00
|
|
|
end
|
|
|
|
private_class_method :expand
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|