diff options
author | Jeremy Evans <code@jeremyevans.net> | 2022-06-06 09:57:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 09:57:32 -0700 |
commit | 7cda7fbbdc14f4262afaa94cdeb5a5987f1eb01a (patch) | |
tree | 6f7da1ed9ce694564c932f9dcc15fd6b04b86c0b /class.c | |
parent | b737998d25f1379117fbf11a578462e6ba12037e (diff) |
Add Module#undefined_instance_methods
Implements [Feature #12655]
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5733
Merged-By: jeremyevans <code@jeremyevans.net>
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -1638,6 +1638,15 @@ ins_methods_pub_i(st_data_t name, st_data_t type, st_data_t ary) return ins_methods_type_i(name, type, ary, METHOD_VISI_PUBLIC); } +static int +ins_methods_undef_i(st_data_t name, st_data_t type, st_data_t ary) +{ + if ((rb_method_visibility_t)type == METHOD_VISI_UNDEF) { + ins_methods_push(name, ary); + } + return ST_CONTINUE; +} + struct method_entry_arg { st_table *list; int recur; @@ -1809,6 +1818,21 @@ rb_class_public_instance_methods(int argc, const VALUE *argv, VALUE mod) /* * call-seq: + * mod.undefined_instance_methods -> array + * + * Returns a list of the undefined instance methods defined in <i>mod</i>. + * The undefined methods of any ancestors are not included. + */ + +VALUE +rb_class_undefined_instance_methods(VALUE mod) +{ + VALUE include_super = Qfalse; + return class_instance_method_list(1, &include_super, mod, 0, ins_methods_undef_i); +} + +/* + * call-seq: * obj.methods(regular=true) -> array * * Returns a list of the names of public and protected methods of |