free_mutant/lib/mutant/subject/method.rb
Markus Schirp 99ab9ff171 Change required Ruby version to >=2.3
* This commit does every 2.3 change required to get the build pass
* None of the changes can be extracted, without changing the build setup
2018-09-12 14:21:24 +00:00

45 lines
901 B
Ruby

# frozen_string_literal: true
module Mutant
class Subject
# Abstract base class for method subjects
class Method < self
# Method name
#
# @return [Expression]
def name
node.children.fetch(self.class::NAME_INDEX)
end
# Match expression
#
# @return [String]
def expression
Expression::Method.new(
method_name: name.to_s,
scope_symbol: self.class::SYMBOL,
scope_name: scope.name
)
end
memoize :expression
# Match expressions
#
# @return [Array<Expression>]
def match_expressions
[expression].concat(context.match_expressions)
end
memoize :match_expressions
private
# The scope
#
# @return [Class, Module]
def scope
context.scope
end
end # Method
end # Subject
end # Mutant