private → self private(symbol, ...) → self
With no arguments, sets the default visibility for subsequently defined methods to private. With arguments, sets the named methods to have private visibility.
module Mod def a() end def b() end private def c() end private :a end Mod.private_instance_methods #=> ["a", "c"]
Source Code
/* * call-seq: * private => self * private(symbol, ...) => self * * With no arguments, sets the default visibility for subsequently * defined methods to private. With arguments, sets the named methods * to have private visibility. * * module Mod * def a() end * def b() end * private * def c() end * private :a * end * Mod.private_instance_methods #=> ["a", "c"] */ static VALUE rb_mod_private(argc, argv, module) int argc; VALUE *argv; VALUE module; { secure_visibility(module); if (argc == 0) { SCOPE_SET(SCOPE_PRIVATE); } else { set_method_visibility(module, argc, argv, NOEX_PRIVATE); } return module; }
<code/>and<pre/>for code samples.