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