Ruby 2.5.0 リファレンスマニュアル > ライブラリ一覧 > 組み込みライブラリ > BasicObjectクラス > singleton_method_removed (private)
singleton_method_removed(name) -> object
[permalink][rdoc]特異メソッドが Module#remove_method により削除された時にインタプリタから呼び出されます。
通常のメソッドの削除に対するフックには Module#method_removedを使います。
class Foo
def singleton_method_removed(name)
puts "singleton method \"#{name}\" was removed"
end
end
obj = Foo.new
def obj.foo
end
class << obj
remove_method :foo
end
#=> singleton method "foo" was removed
[SEE_ALSO] Module#method_removed,BasicObject#singleton_method_added,BasicObject#singleton_method_undefined