[#106341] [Ruby master Bug#18369] users.detect(:name, "Dorian") as shorthand for users.detect { |user| user.name == "Dorian" } — dorianmariefr <noreply@...>
Issue #18369 has been reported by dorianmariefr (Dorian Mari辿).
14 messages
2021/11/30
[#106351] [Ruby master Bug#18371] Release branches (release information in general) — "tenderlovemaking (Aaron Patterson)" <noreply@...>
Issue #18371 has been reported by tenderlovemaking (Aaron Patterson).
7 messages
2021/11/30
[ruby-core:106076] [Ruby master Feature#12737] Module#defined_refinements
From:
"shugo (Shugo Maeda)" <noreply@...>
Date:
2021-11-16 04:43:33 UTC
List:
ruby-core #106076
Issue #12737 has been updated by shugo (Shugo Maeda).
Eregon (Benoit Daloze) wrote in #note-4:
> Should the code in the description be `p M.defined_refinements`?
Yes.
> I'm not sure to understand the use case, isn't `using M` doing the same as that `for`?
Forget the following example. It was not a good idea.
```
for klass, refinement in Module.defined_refinements
klass.prepend(refinement)
end
```
Module#defined_refinements is a reflection API for debugging purposes.
You can get a similar result of Module.used_refinements using Module.use_modules and Module#defined_refinements except that Module.used_refinements only returns refinements defined at the time when modules are used.
----------------------------------------
Feature #12737: Module#defined_refinements
https://bugs.ruby-lang.org/issues/12737#change-94665
* 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 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
```
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>