From: shevegen@... Date: 2016-06-30T03:51:53+00:00 Subject: [ruby-core:76208] [Ruby trunk Feature#12534] Refinements: refine modules as well Issue #12534 has been updated by Robert A. Heiler. Interesting. I was not aware of this. It is however mentioned in the documentation: http://ruby-doc.org/core-2.3.1/doc/syntax/refinements_rdoc.html Quote: "Refinements only modify classes, not modules so the argument must be a class." As to why, I don't know either. Perhaps the documentation can add some words to briefly state whether this is on purpose or not. ---------------------------------------- Feature #12534: Refinements: refine modules as well https://bugs.ruby-lang.org/issues/12534#change-59424 * Author: Tiago Cardoso * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Refinements were added as a feature to scope monkey-patches on ruby core elements. This works for elements such as String, Array (all classes), but not for modules (Enumerable, Timeout...). This might be related to refinements not working for singleton classes (for example, I can't define a class method inside a refine block). This code is evaluated, but the method is undefined: module Extension refine Array do def self.foo ; puts "bar" ; end end end This code breaks: module Extension refine Kernel do def foo ; puts "bar" ; end end end -- https://bugs.ruby-lang.org/ Unsubscribe: