Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

BasicObject#singleton_method_removed

(::Symbol name) -> nil
singleton_method_removed(symbol)

Invoked as a callback whenever a singleton method is removed from the receiver.

Example
module Chatty
  def Chatty.singleton_method_removed(id)
    puts "Removing #{id.id2name}"
  end
  def self.one()     end
  def two()          end
  def Chatty.three() end
  class << self
    remove_method :three
    remove_method :one
  end
end

produces:

Example
Removing three
Removing one