2013-01-13 22:25:49 +01:00
|
|
|
module Mutant
|
|
|
|
class Subject
|
|
|
|
# Abstract base class for method subjects
|
|
|
|
class Method < self
|
|
|
|
|
|
|
|
# Test if method is public
|
|
|
|
#
|
2014-06-15 19:27:57 +00:00
|
|
|
# @return [Boolean]
|
2013-01-13 22:25:49 +01:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
abstract_method :public?
|
|
|
|
|
2013-06-15 16:32:40 +02:00
|
|
|
# Return method name
|
2013-06-14 20:29:36 +02:00
|
|
|
#
|
2013-06-15 16:32:40 +02:00
|
|
|
# @return [Symbol]
|
2013-06-14 20:29:36 +02:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-06-15 16:32:40 +02:00
|
|
|
def name
|
|
|
|
node.children[self.class::NAME_INDEX]
|
2013-06-14 20:29:36 +02:00
|
|
|
end
|
2013-06-14 20:23:46 +02:00
|
|
|
|
2013-08-04 18:49:42 +02:00
|
|
|
# Return match expression
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2014-06-28 20:47:46 +00:00
|
|
|
def expression
|
2014-06-29 23:16:34 +00:00
|
|
|
Expression.parse("#{context.identification}#{self.class::SYMBOL}#{name}")
|
2013-08-04 18:49:42 +02:00
|
|
|
end
|
2014-06-28 20:47:46 +00:00
|
|
|
memoize :expression
|
2013-08-04 18:49:42 +02:00
|
|
|
|
2014-10-08 15:16:05 +00:00
|
|
|
# Return match expressions
|
|
|
|
#
|
|
|
|
# @return [Array<Expression>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def match_expressions
|
|
|
|
[expression].concat(context.match_expressions)
|
|
|
|
end
|
|
|
|
memoize :match_expressions
|
|
|
|
|
2013-06-15 16:32:40 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
# Return scope
|
2013-01-21 23:54:25 +01:00
|
|
|
#
|
2013-06-15 16:32:40 +02:00
|
|
|
# @return [Class, Module]
|
2013-01-21 23:54:25 +01:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
2013-06-15 16:32:40 +02:00
|
|
|
def scope
|
|
|
|
context.scope
|
2013-01-21 23:54:25 +01:00
|
|
|
end
|
|
|
|
|
2013-06-14 20:23:46 +02:00
|
|
|
end # Method
|
|
|
|
end # Subject
|
|
|
|
end # Mutant
|