From: "shugo (Shugo Maeda)" Date: 2021-11-18T05:55:18+00:00 Subject: [ruby-core:106115] [Ruby master Feature#12737] Module#defined_refinements Issue #12737 has been updated by shugo (Shugo Maeda). Considerations raised by Matz at the developers meeting on 2021-11-18: 1. Is the name **defined**_refinements appropriate? other proposals: * configured_refinements (by tenderlove) * refinements * consistent with Module#constants * contained_refinements 2. Should the return value be an Array instead of a Hash? pros: * consistent with Module.used_refinements cons: * A new API like Refinement#refined_class (or target_class) is needed to know the refined class. * `M.defined_refinements.find { |r| r.refined_class == Integer }` is longer than `M.defined_refinements[Integer]`. ---------------------------------------- Feature #12737: Module#defined_refinements https://bugs.ruby-lang.org/issues/12737#change-94712 * Author: shugo (Shugo Maeda) * Status: Assigned * Priority: Normal ---------------------------------------- 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 ``` -- https://bugs.ruby-lang.org/ Unsubscribe: