36件ヒット
[1-36件を表示]
(0.014秒)
別のキーワード
ライブラリ
- ビルトイン (36)
クラス
- BasicObject (12)
- Module (24)
キーワード
-
method
_ undefined (12) -
singleton
_ method _ undefined (12)
検索結果
先頭3件
-
Module
# undef _ method(*name) -> self (24226.0) -
このモジュールのインスタンスメソッド name を未定義にします。
...end
end
class B < A
def ok
puts 'B'
end
end
B.new.ok # => B
# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B.new.ok # => NameError
# remove_method の場合はスーパ......remove_method :ok
end
B.new.ok # => A
//}
また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることです。
//emlist[例][ruby]{
module M1
def foo
end
def self.moo
undef foo
end
end
M1.instance_methods false #=> ["foo"]......M1.moo
M1.instance_methods false #=> []
module M2
def foo
end
def self.moo
undef_method :foo
end
end
M2.instance_methods false #=> ["foo"]
M2.moo
M2.instance_methods false #=> []
//}... -
BasicObject
# singleton _ method _ undefined(name) -> object (6123.0) -
特異メソッドが Module#undef_method または undef により未定義にされた時にインタプリタから呼び出されます。
...特異メソッドが Module#undef_method または
undef により未定義にされた時にインタプリタから呼び出されます。
通常のメソッドの未定義に対するフックには
Module#method_undefined を使います。
@param name 未定義にされたメソッド名......ngleton_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
//}
@s......ee Module#method_undefined,BasicObject#singleton_method_added,BasicObject#singleton_method_removed , d:spec/def#undef... -
Module
# method _ undefined(name) -> () (6123.0) -
このモジュールのインスタンスメソッド name が Module#undef_method によって削除されるか、 undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。
...メソッド name が
Module#undef_method によって削除されるか、
undef 文により未定義にされると、インタプリタがこのメソッドを呼び出します。
特異メソッドの削除をフックするには
BasicObject#singleton_method_undefined
を使います。
@pa......ド名が Symbol で渡されます。
//emlist[例][ruby]{
class C
def C.method_undefined(name)
puts "method C\##{name} was undefined"
end
def foo
end
def bar
end
undef_method :foo
undef bar
end
//}
実行結果:
method C#foo was undefined
method C#bar was undefined...