[ruby-core:76314] [Ruby trunk Feature#12534][Feedback] Refinements: refine modules as well

From: shugo@...
Date: 2016-07-08 07:18:10 UTC
List: ruby-core #76314
Issue #12534 has been updated by Shugo Maeda.

Status changed from Open to Feedback
Assignee set to Shugo Maeda

There is an implementation difficulty when refining modules and calling `super` in that refinement.

One solution is prohibiting `super` in a refinement for a module.
Other proposals (and patches) are welcome.


----------------------------------------
Feature #12534: Refinements: refine modules as well
https://bugs.ruby-lang.org/issues/12534#change-59550

* Author: Tiago Cardoso
* Status: Feedback
* Priority: Normal
* Assignee: Shugo Maeda
----------------------------------------
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: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next