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