From 0336ec334f7eb66d2cf05bd7a29d748780d6044e Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Sun, 9 Jan 2011 00:13:57 +0000 Subject: [PATCH] method transplanting: Allow to set an UnboundMethod to any module. It's time to grow up, remove the security nets. --- proc.c | 11 ----------- 1 files changed, 0 insertions(+), 11 deletions(-) diff --git a/proc.c b/proc.c index 7df2ec8..652b3e1 100644 --- a/proc.c +++ b/proc.c @@ -1293,17 +1293,6 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod) if (rb_obj_is_method(body)) { struct METHOD *method = (struct METHOD *)DATA_PTR(body); VALUE rclass = method->rclass; - if (rclass != mod && !RTEST(rb_class_inherited_p(mod, rclass))) { - if (FL_TEST(rclass, FL_SINGLETON)) { - rb_raise(rb_eTypeError, - "can't bind singleton method to a different class"); - } - else { - rb_raise(rb_eTypeError, - "bind argument must be a subclass of %s", - rb_class2name(rclass)); - } - } rb_method_entry_set(mod, id, &method->me, noex); } else if (rb_obj_is_proc(body)) { -- 1.7.3.4