Project

General

Profile

Feature #12737

Module#defined_refinements

Added by shugo (Shugo Maeda) about 3 years ago.

Status:
Open
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:77215]

Description

How about to provide Module#defined_refinements, which returns the refinements defined in the receiver as a Hash, as follows:

module M
  refine String do
    $M_String = self
  end

  refine Integer do
    $M_Integer = self
  end
end

p Module.defined_refinements #=> {String => $M_String, Integer => $M_Integer}

By Module#defined_refinements, you can activate refinements globally:

for klass, refinement in Module.defined_refinements
  klass.prepend(refinement)
end

Related issues

Related to Ruby master - Feature #9704: Refinements as files instead of modulesOpenActions

History

#1

Updated by shugo (Shugo Maeda) about 3 years ago

  • Related to Feature #9704: Refinements as files instead of modules added

Also available in: Atom PDF