diff options
author | Jeremy Evans <code@jeremyevans.net> | 2021-11-18 10:51:14 -0800 |
---|---|---|
committer | Jeremy Evans <code@jeremyevans.net> | 2021-11-18 10:51:14 -0800 |
commit | ab737b19197c63b84dad9944045a2fd2dc369264 (patch) | |
tree | 366ce335ca57ed53fc60929fe2f6d6af93c881d4 | |
parent | 75ecbda438670ec12641d1324d0e81a52ee02e0a (diff) | |
download | ruby-ab737b19197c63b84dad9944045a2fd2dc369264.tar.gz |
Update documentation for Module#{private,public,protected,module_function}
Also, update NEWS for this change and the Kernel#load change.
-rw-r--r-- | NEWS.md | 15 | ||||
-rw-r--r-- | vm_method.c | 41 |
2 files changed, 42 insertions, 14 deletions
@@ -143,6 +143,13 @@ Outstanding ones only. * 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. 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. `$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 9d0c59c01e..7c5147d4d4 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 /* * 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) /* * 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) /* * 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) /* * 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) * 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 |