summaryrefslogtreecommitdiff
path: root/variable.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2019-05-07 12:52:24 +0200
committerNobuyoshi Nakada <nobu@ruby-lang.org>2019-06-21 17:28:37 +0900
commitfb85a428605265a8fd449b0702a4dd88cb6f3b20 (patch)
tree0e5f9df92b010b026cfab40a54a1778f55f93e61 /variable.c
parent887163beb8f27c5400cd04dbf98c474ed035526f (diff)
Add an optional `inherit` argument to Module#autoload?
[Feature #15777] Closes: https://github.com/ruby/ruby/pull/2173
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/variable.c b/variable.c
index be0eee1df3..616c4852c0 100644
--- a/variable.c
+++ b/variable.c
@@ -2332,10 +2332,17 @@ rb_autoload_load(VALUE mod, ID id)
VALUE
rb_autoload_p(VALUE mod, ID id)
{
+ return rb_autoload_at_p(mod, id, Qtrue);
+}
+
+VALUE
+rb_autoload_at_p(VALUE mod, ID id, VALUE recur)
+{
VALUE load;
struct autoload_data_i *ele;
while (!autoload_defined_p(mod, id)) {
+ if (!RTEST(recur)) return Qnil;
mod = RCLASS_SUPER(mod);
if (!mod) return Qnil;
}