summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2022-06-06 09:57:32 -0700
committerGitHub <noreply@github.com>2022-06-06 09:57:32 -0700
commit7cda7fbbdc14f4262afaa94cdeb5a5987f1eb01a (patch)
tree6f7da1ed9ce694564c932f9dcc15fd6b04b86c0b /class.c
parentb737998d25f1379117fbf11a578462e6ba12037e (diff)
downloadruby-7cda7fbbdc14f4262afaa94cdeb5a5987f1eb01a.tar.gz
Add Module#undefined_instance_methods
Implements [Feature #12655] Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
Diffstat (limited to 'class.c')
-rw-r--r--class.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/class.c b/class.c
index 7b91f06229..6db373edc1 100644
--- a/class.c
+++ b/class.c
@@ -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