ruby-changes:69812
From: Jeremy <ko1@a...>
Date: Fri, 19 Nov 2021 03:52:16 +0900 (JST)
Subject: [ruby-changes:69812] ab737b1919 (master): Update documentation for Module#{private, public, protected, module_function}
https://git.ruby-lang.org/ruby.git/commit/?id=ab737b1919 From ab737b19197c63b84dad9944045a2fd2dc369264 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Thu, 18 Nov 2021 10:51:14 -0800 Subject: Update documentation for Module#{private,public,protected,module_function} Also, update NEWS for this change and the Kernel#load change. --- NEWS.md | 15 +++++++++++++++ vm_method.c | 41 +++++++++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 14 deletions(-) diff --git a/NEWS.md b/NEWS.md index 5c2cac23d13..2e4cbc6742d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -143,6 +143,13 @@ Outstanding ones only. https://github.com/ruby/ruby/blob/trunk/NEWS.md#L143 * Integer.try_convert is added. [[Feature #15211]] +* Kernel + + + * Kernel#load now accepts a module as the second argument, + and will load the file using the given module as the top + level module. [[Feature #6210]] + * MatchData * MatchData#match is added [[Feature #18172]] @@ -156,6 +163,12 @@ Outstanding ones only. https://github.com/ruby/ruby/blob/trunk/NEWS.md#L163 modify the ancestor chain if the receiver has already prepended the argument. [[Bug #17423]] + * Module#private, #public, #protected, and #module_function will + now return their arguments. If a single argument is given, it + is returned. If no arguments are given, nil is returned. If + multiple arguments are given, they are returned as an array. + [[Feature #12495]] + * Process * Process.\_fork is added. This is a core method for fork(2). @@ -398,7 +411,9 @@ See [the repository](https://github.com/ruby/error_highlight) in detail. https://github.com/ruby/ruby/blob/trunk/NEWS.md#L411 `$VERBOSE` is `nil`. [[Feature #17798]] [Bug #4443]: https://bugs.ruby-lang.org/issues/4443 +[Feature #6210]: https://bugs.ruby-lang.org/issues/6210 [Feature #12194]: https://bugs.ruby-lang.org/issues/12194 +[Feature #12495]: https://bugs.ruby-lang.org/issues/12495 [Feature #14256]: https://bugs.ruby-lang.org/issues/14256 [Feature #14394]: https://bugs.ruby-lang.org/issues/14394 [Feature #14579]: https://bugs.ruby-lang.org/issues/14579 diff --git a/vm_method.c b/vm_method.c index 9d0c59c01e6..7c5147d4d42 100644 --- a/vm_method.c +++ b/vm_method.c @@ -2130,16 +2130,19 @@ set_visibility(int argc, const VALUE *argv, VALUE module, rb_method_visibility_t https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2130 /* * call-seq: - * public -> self - * public(symbol, ...) -> self - * public(string, ...) -> self - * public(array) -> self + * public -> nil + * public(method_name) -> method_name + * public(method_name, method_name, ...) -> array + * public(array) -> array * * 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. */ static VALUE @@ -2150,16 +2153,19 @@ rb_mod_public(int argc, VALUE *argv, VALUE module) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2153 /* * call-seq: - * protected -> self - * protected(symbol, ...) -> self - * protected(string, ...) -> self - * protected(array) -> self + * protected -> nil + * protected(method_name) -> method_name + * protected(method_name, method_name, ...) -> array + * protected(array) -> array * * With no arguments, sets the default visibility for subsequently * defined methods to protected. With arguments, sets the named methods * to have protected 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. * * If a method has protected visibility, it is callable only where * <code>self</code> of the context is the same as the method. @@ -2179,16 +2185,19 @@ rb_mod_protected(int argc, VALUE *argv, VALUE module) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2185 /* * call-seq: - * private -> self - * private(symbol, ...) -> self - * private(string, ...) -> self - * private(array) -> self + * private -> nil + * private(method_name) -> method_name + * private(method_name, method_name, ...) -> array + * private(array) -> array * * With no arguments, sets the default visibility for subsequently * defined methods to private. With arguments, sets the named methods * to have private 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. * * module Mod * def a() end @@ -2423,8 +2432,9 @@ top_ruby2_keywords(int argc, VALUE *argv, VALUE module) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2432 /* * call-seq: - * module_function(symbol, ...) -> self - * module_function(string, ...) -> self + * module_function -> nil + * module_function(method_name) -> method_name + * module_function(method_name, method_name, ...) -> array * * Creates module functions for the named methods. These functions may * be called with the module as a receiver, and also become available @@ -2434,6 +2444,9 @@ top_ruby2_keywords(int argc, VALUE *argv, VALUE module) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2444 * used with no arguments, subsequently defined methods become module * functions. * String arguments are converted to symbols. + * 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. * * module Mod * def one -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/