From: marcandre-ruby-core@... Date: 2020-12-07T20:19:20+00:00 Subject: [ruby-core:101291] [Ruby master Bug#17374] Refined methods aren't visible from a refinement's module Issue #17374 has been updated by marcandre (Marc-Andre Lafortune). Eregon (Benoit Daloze) wrote in #note-4: > In the original example, there is no way to know that Implementation will be followed by `refine`, and that the methods declared there should be affected. > > What you are asking is I think dynamic rebinding I might be confused as to what dynamic rebinding is; for me the constraint was that there could not be later redefinitions of refinements, that everything had to had been already defined (which is the case). When `refine { include Mod }`, I would like the `include` to "duplicate" the *current* methods of `Mod`, just as if I had written them with `def` at that point. Ideally they would be in a different layer than the current refinement, so you could use `prepend`, `def` and `include` on the same method, but at this point that is minor. Note that I tried `refine { define_method :foo, Mod.instance_method(:foo) }` and that does not work either. > because what should happen if: > ```ruby > module R1 > refine Foo do > prepend Foo::Implementation > end > end > > module R2 > refine Foo do > prepend Foo::Implementation > end > end > ``` More or less the same as if you replaced the `prepend` with the `def`s of `Foo::Implementation` as they were defined at the time. ---------------------------------------- Bug #17374: Refined methods aren't visible from a refinement's module https://bugs.ruby-lang.org/issues/17374#change-88975 * Author: marcandre (Marc-Andre Lafortune) * Status: Open * Priority: Normal * Assignee: shugo (Shugo Maeda) * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- -- https://bugs.ruby-lang.org/ Unsubscribe: