2013-01-13 22:25:49 +01:00
|
|
|
module Mutant
|
|
|
|
class Subject
|
|
|
|
# Abstract base class for method subjects
|
|
|
|
class Method < self
|
|
|
|
|
2015-07-03 15:21:39 +00:00
|
|
|
# Method name
|
2013-06-14 20:29:36 +02:00
|
|
|
#
|
2015-06-21 14:44:33 +00:00
|
|
|
# @return [Expression]
|
2013-06-15 16:32:40 +02:00
|
|
|
def name
|
2015-06-21 14:44:33 +00:00
|
|
|
node.children.fetch(self.class::NAME_INDEX)
|
2013-06-14 20:29:36 +02:00
|
|
|
end
|
2013-06-14 20:23:46 +02:00
|
|
|
|
2015-07-03 15:21:39 +00:00
|
|
|
# Match expression
|
2013-08-04 18:49:42 +02:00
|
|
|
#
|
|
|
|
# @return [String]
|
2014-06-28 20:47:46 +00:00
|
|
|
def expression
|
2015-06-21 14:44:33 +00:00
|
|
|
Expression::Method.new(
|
2015-11-15 20:13:48 +00:00
|
|
|
method_name: name.to_s,
|
2015-06-21 14:44:33 +00:00
|
|
|
scope_symbol: self.class::SYMBOL,
|
2015-11-15 20:13:48 +00:00
|
|
|
scope_name: scope.name
|
2015-06-21 14:44:33 +00:00
|
|
|
)
|
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
|
|
|
|
2015-07-03 15:21:39 +00:00
|
|
|
# Match expressions
|
2014-10-08 15:16:05 +00:00
|
|
|
#
|
|
|
|
# @return [Array<Expression>]
|
|
|
|
def match_expressions
|
|
|
|
[expression].concat(context.match_expressions)
|
|
|
|
end
|
|
|
|
memoize :match_expressions
|
|
|
|
|
2013-06-15 16:32:40 +02:00
|
|
|
private
|
|
|
|
|
2015-07-03 15:21:39 +00:00
|
|
|
# The scope
|
2013-01-21 23:54:25 +01:00
|
|
|
#
|
2013-06-15 16:32:40 +02:00
|
|
|
# @return [Class, Module]
|
|
|
|
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
|