End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Module#private_method_defined?
mod.private_method_defined?(symbol, inherit=true) → true or false
mod.private_method_defined?(string, inherit=true) → true or false
vm_method.c
View on GitHub ↗
static VALUE
rb_mod_private_method_defined(int argc, VALUE *argv, VALUE mod)
{
return check_definition(mod, argc, argv, METHOD_VISI_PRIVATE);
}
Returns true if the named private method is defined by mod. If inherit is set, the lookup will also search mod’s ancestors. String arguments are converted to symbols.
Example
module A def method1() end end class B private def method2() end end class C < B include A def method3() end end A.method_defined? :method1 #=> true C.private_method_defined? "method1" #=> false C.private_method_defined? "method2" #=> true C.private_method_defined? "method2", true #=> true C.private_method_defined? "method2", false #=> false C.method_defined? "method2" #=> false
See also
#private_instance_methods
#protected
#private_constant
#protected_instance_methods
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0