>>>>> "M" == Mauricio =?iso-8859-1?Q?Fern=E1ndez?= <Mauricio> writes:

M> How do I do within singleton_method_added to remove a singleton method
M> if it matches some :name?

pigeon% cat b.rb
#!/usr/bin/ruby
class A
  def self.singleton_method_added(id)
     puts "Adding singleton method #{id} to #{self}"
     if id != :singleton_method_added
        class << self; self; end.send(:remove_method, id)
     end
  end
end

class A
  def self.a
     p "A::a"
  end
end

A.a
pigeon% 

pigeon% b.rb
Adding singleton method singleton_method_added to A
Adding singleton method a to A
./b.rb:17: undefined method `a' for A:Class (NameError)
pigeon% 


Guy Decoux