lib/mutant/matcher/method/metaclass.rb in mutant-0.11.18 vs lib/mutant/matcher/method/metaclass.rb in mutant-0.11.19
- old
+ new
@@ -9,16 +9,13 @@
# plumbing will be in place in the subject for that to work
class Metaclass < self
# New singleton method matcher
#
- # @param [Class, Module] scope
- # @param [Symbol] method_name
- #
# @return [Matcher::Method::Singleton]
- def self.new(scope, method_name)
- super(scope, method_name, Evaluator)
+ def self.new(scope:, target_method:)
+ super(scope: scope, target_method: target_method, evaluator: Evaluator)
end
# Metaclass method evaluator
class Evaluator < Evaluator
# Terminology note: the "receiver" is the `self` in `class << self`
@@ -32,29 +29,19 @@
'unable to match'
private
def match?(node)
- n_def?(node) &&
- name?(node) &&
- line?(node) &&
- metaclass_receiver?(node)
+ name?(node) && metaclass_receiver?(node)
end
def metaclass_receiver?(node)
candidate = metaclass_containing(node)
candidate && metaclass_target?(candidate)
end
def metaclass_containing(node)
- AST::FindMetaclassContaining.call(ast, node)
- end
-
- def line?(node)
- node
- .location
- .line
- .equal?(source_line)
+ AST::FindMetaclassContaining.call(ast: ast, target: node)
end
def name?(node)
node.children.fetch(NAME_INDEX).equal?(method_name)
end