instance method
Module#public
() -> nil
(::Symbol method_name) -> ::Symbol
(::Symbol, ::Symbol, *::Symbol method_name) -> ::Array[::Symbol]
(::string method_name) -> ::string
(::interned, ::interned, *::interned method_name) -> ::Array[::interned]
(::Array[::interned]) -> ::Array[::interned]
public → nil
public(method_name) → method_name
public(method_name, method_name, ...) → array
public(array) → array
vm_method.c
View on GitHub ↗
static VALUE
rb_mod_public(int argc, VALUE *argv, VALUE module)
{
return set_visibility(argc, argv, module, METHOD_VISI_PUBLIC);
}
With no arguments, sets the default visibility for subsequently defined methods to public. With arguments, sets the named methods to have public visibility. String arguments are converted to symbols. An Array of Symbols and/or Strings is also accepted. If a single argument is passed, it is returned. If no argument is passed, nil is returned. If multiple arguments are passed, the arguments are returned as an array.
Ruby version changes
-
3.0
-
Module#public,Module#protected,Module#private,Module#public_class_method,Module#private_class_method, toplevel “private” and “public” methods now accept single array argument with a list of method names. [Feature #17314]
-
See also
#protected_method_defined?
#public_class_method
#protected_instance_methods
#public_constant
also in
4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0