Project

General

Profile

Actions

Feature #12737

closed

Module#defined_refinements

Added by shugo (Shugo Maeda) about 8 years ago. Updated over 1 year ago.

Status:
Closed
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 M.defined_refinements #=> {String => $M_String, Integer => $M_Integer}

By Module#defined_refinements, you can activate refinements globally:

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

Related issues 3 (1 open2 closed)

Related to Ruby master - Feature #9704: Refinements as files instead of modulesAssignedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Feature #14332: Module.used_refinements to list refinement modulesClosedshugo (Shugo Maeda)Actions
Related to Ruby master - Feature #19714: Add Refinement#refined_moduleClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0