free_mutant/lib/mutant/subject/method/singleton.rb
2014-03-15 17:00:20 +00:00

41 lines
805 B
Ruby

# encoding: utf-8
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?
# Prepare subject for mutation insertion
#
# @return [self]
#
# @api private
#
def prepare
scope.singleton_class.send(:undef_method, name)
self
end
end # Singleton
end # Method
end # Subject
end # Mutant