Project

General

Profile

Actions

Feature #12534

closed

Refinements: refine modules as well

Added by chucke (Tiago Cardoso) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Target version:
-
[ruby-core:76199]

Description

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0