2013-01-13 16:25:49 -05:00
|
|
|
module Mutant
|
|
|
|
class Subject
|
|
|
|
# Abstract base class for method subjects
|
|
|
|
class Method < self
|
|
|
|
|
|
|
|
# Test if method is public
|
|
|
|
#
|
2014-06-15 15:27:57 -04:00
|
|
|
# @return [Boolean]
|
2013-01-13 16:25:49 -05:00
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
abstract_method :public?
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Method name
|
2013-06-14 14:29:36 -04:00
|
|
|
#
|
2015-06-21 10:44:33 -04:00
|
|
|
# @return [Expression]
|
2013-06-14 14:29:36 -04:00
|
|
|
#
|
|
|
|
# @api private
|
2013-06-15 10:32:40 -04:00
|
|
|
def name
|
2015-06-21 10:44:33 -04:00
|
|
|
node.children.fetch(self.class::NAME_INDEX)
|
2013-06-14 14:29:36 -04:00
|
|
|
end
|
2013-06-14 14:23:46 -04:00
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Match expression
|
2013-08-04 12:49:42 -04:00
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
#
|
|
|
|
# @api private
|
2014-06-28 16:47:46 -04:00
|
|
|
def expression
|
2015-06-21 10:44:33 -04:00
|
|
|
Expression::Method.new(
|
|
|
|
scope_symbol: self.class::SYMBOL,
|
|
|
|
scope_name: scope.name,
|
|
|
|
method_name: name.to_s
|
|
|
|
)
|
2013-08-04 12:49:42 -04:00
|
|
|
end
|
2014-06-28 16:47:46 -04:00
|
|
|
memoize :expression
|
2013-08-04 12:49:42 -04:00
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# Match expressions
|
2014-10-08 11:16:05 -04:00
|
|
|
#
|
|
|
|
# @return [Array<Expression>]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
def match_expressions
|
|
|
|
[expression].concat(context.match_expressions)
|
|
|
|
end
|
|
|
|
memoize :match_expressions
|
|
|
|
|
2013-06-15 10:32:40 -04:00
|
|
|
private
|
|
|
|
|
2015-07-03 11:21:39 -04:00
|
|
|
# The scope
|
2013-01-21 17:54:25 -05:00
|
|
|
#
|
2013-06-15 10:32:40 -04:00
|
|
|
# @return [Class, Module]
|
2013-01-21 17:54:25 -05:00
|
|
|
#
|
|
|
|
# @api private
|
2013-06-15 10:32:40 -04:00
|
|
|
def scope
|
|
|
|
context.scope
|
2013-01-21 17:54:25 -05:00
|
|
|
end
|
|
|
|
|
2013-06-14 14:23:46 -04:00
|
|
|
end # Method
|
|
|
|
end # Subject
|
|
|
|
end # Mutant
|