free_mutant/lib/mutant/subject/method.rb

60 lines
1.1 KiB
Ruby
Raw Normal View History

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?
# Method name
#
# @return [Expression]
#
# @api private
def name
node.children.fetch(self.class::NAME_INDEX)
end
2013-06-14 14:23:46 -04:00
# Match expression
#
# @return [String]
#
# @api private
def expression
Expression::Method.new(
scope_symbol: self.class::SYMBOL,
scope_name: scope.name,
method_name: name.to_s
)
end
memoize :expression
# Match expressions
#
# @return [Array<Expression>]
#
# @api private
def match_expressions
[expression].concat(context.match_expressions)
end
memoize :match_expressions
private
# The scope
#
# @return [Class, Module]
#
# @api private
def scope
context.scope
end
2013-06-14 14:23:46 -04:00
end # Method
end # Subject
end # Mutant