free_mutant/lib/mutant/subject/method.rb

83 lines
1.5 KiB
Ruby
Raw Normal View History

2013-01-13 22:25:49 +01:00
module Mutant
class Subject
# Abstract base class for method subjects
class Method < self
# Test if method is public
#
# @return [true]
# if method is public
#
# @return [false]
# otherwise
#
# @api private
#
abstract_method :public?
# Instance method subjects
class Instance < self
# Test if method is public
#
# @return [true]
# if method is public
#
# @return [false]
# otherwise
#
# @api private
#
def public?
scope.public_method_defined?(method_name)
end
memoize :public?
private
# Return subtype identifier
#
# @return [String]
#
# @api private
#
def subtype
"#{context.identification}##{node.name}"
2013-01-13 22:25:49 +01:00
end
end
# Singleton method subjects
class Singleton < self
# Test if method is public
#
# @return [true]
# if method is public
#
# @return [false]
# otherwise
#
# @api private
#
def public?
scope.singleton_class.public_method_defined?(method_name)
end
memoize :public?
private
# Return subtype identifier
#
# @return [String]
#
# @api private
#
def subtype
2013-01-15 23:46:05 +01:00
"#{context.identification}.#{node.body.name}"
2013-01-13 22:25:49 +01:00
end
end
end
end
end