2013-07-28 19:03:06 -04:00
|
|
|
# encoding: utf-8
|
|
|
|
|
2013-07-04 18:54:50 -04:00
|
|
|
module Mutant
|
|
|
|
class Subject
|
|
|
|
class Method
|
|
|
|
# Singleton method subjects
|
|
|
|
class Singleton < self
|
|
|
|
|
|
|
|
NAME_INDEX = 1
|
|
|
|
SYMBOL = '.'.freeze
|
|
|
|
|
|
|
|
# Test if method is public
|
|
|
|
#
|
|
|
|
# @return [true]
|
|
|
|
# if method is public
|
|
|
|
#
|
|
|
|
# @return [false]
|
|
|
|
# otherwise
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def public?
|
|
|
|
scope.singleton_class.public_method_defined?(name)
|
|
|
|
end
|
|
|
|
memoize :public?
|
|
|
|
|
2014-03-15 13:00:18 -04:00
|
|
|
# Prepare subject for mutation insertion
|
|
|
|
#
|
|
|
|
# @return [self]
|
|
|
|
#
|
|
|
|
# @api private
|
|
|
|
#
|
|
|
|
def prepare
|
|
|
|
scope.singleton_class.send(:undef_method, name)
|
|
|
|
self
|
|
|
|
end
|
|
|
|
|
2013-07-04 18:54:50 -04:00
|
|
|
end # Singleton
|
|
|
|
end # Method
|
|
|
|
end # Subject
|
|
|
|
end # Mutant
|