diff --git a/core/src/main/java/org/jruby/RubyModule.java b/core/src/main/java/org/jruby/RubyModule.java index 005af6f9e0b..550224ff56c 100644 --- a/core/src/main/java/org/jruby/RubyModule.java +++ b/core/src/main/java/org/jruby/RubyModule.java @@ -1444,11 +1444,9 @@ public void undef(ThreadContext context, String name) { } methodLocation.addMethod(name, UndefinedMethod.getInstance()); - if (isSingleton()) { - ((MetaClass) this).getAttached().callMethod(context, "singleton_method_undefined", runtime.newSymbol(name)); - } else { - callMethod(context, "method_undefined", runtime.newSymbol(name)); - } + RubySymbol nameSymbol = runtime.newSymbol(name); + + methodUndefined(context, nameSymbol); } @JRubyMethod(name = "include?") @@ -1567,11 +1565,7 @@ public void removeMethod(ThreadContext context, String id) { invalidateCacheDescendants(); } - if (isSingleton()) { - ((MetaClass) this).getAttached().callMethod(context, "singleton_method_removed", name); - } else { - callMethod(context, "method_removed", name); - } + methodRemoved(context, name); } private static void warnMethodRemoval(final ThreadContext context, final String id) { @@ -2306,6 +2300,22 @@ protected void methodAdded(ThreadContext context, RubySymbol identifier) { } } + private void methodUndefined(ThreadContext context, RubySymbol nameSymbol) { + if (isSingleton()) { + ((MetaClass) this).getAttached().callMethod(context, "singleton_method_undefined", nameSymbol); + } else { + callMethod(context, "method_undefined", nameSymbol); + } + } + + private void methodRemoved(ThreadContext context, RubySymbol name) { + if (isSingleton()) { + ((MetaClass) this).getAttached().callMethod(context, "singleton_method_removed", name); + } else { + callMethod(context, "method_removed", name); + } + } + /** set_method_visibility * */