diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-19 14:41:59 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-09-20 13:07:58 +0900 |
| commit | 683baec4f0249d1677863ced20a7921734e6faed (patch) | |
| tree | 5ea77f64a8d23544af941dde75cfa66514ffa6ba /src | |
| parent | 01ce5824f0c74cb982b8a7378a15ad1d4f5653e9 (diff) | |
| download | mruby-683baec4f0249d1677863ced20a7921734e6faed.tar.gz mruby-683baec4f0249d1677863ced20a7921734e6faed.zip | |
Add optional argument to `Module#class_variables`.
Diffstat (limited to 'src')
| -rw-r--r-- | src/variable.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/variable.c b/src/variable.c index 06756a69f..cb06a8341 100644 --- a/src/variable.c +++ b/src/variable.c @@ -595,7 +595,7 @@ cv_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p) /* 15.2.2.4.19 */ /* * call-seq: - * mod.class_variables -> array + * mod.class_variables(inherit=true) -> array * * Returns an array of the names of class variables in <i>mod</i>. * @@ -613,11 +613,14 @@ mrb_mod_class_variables(mrb_state *mrb, mrb_value mod) { mrb_value ary; struct RClass *c; + mrb_bool inherit = TRUE; + mrb_get_args(mrb, "|b", &inherit); ary = mrb_ary_new(mrb); c = mrb_class_ptr(mod); while (c) { iv_foreach(mrb, c->iv, cv_i, &ary); + if (!inherit) break; c = c->super; } return ary; |
