From: kevin.deisz@... Date: 2018-01-10T18:22:56+00:00 Subject: [ruby-core:84819] [Ruby trunk Feature#14344] refine at class level Issue #14344 has been updated by kddeisz (Kevin Deisz). I was proposing the former, which would be to have `refine` be a class method that would effectively be the same as `using` with an anonymous module. I get what you're saying about it being different between a class and a module but I'm not sure I necessary see that as a problem. Class and Module already don't have perfect parity (allocate, new, superclass) so it doesn't seem like we need to enforce that. I doubt people would be caught off guard by a change in the semantics of the method between Module and Class because it doesn't seem like it would be a common practice to be switching constants back and forth between modules and classes all the time. ---------------------------------------- Feature #14344: refine at class level https://bugs.ruby-lang.org/issues/14344#change-69532 * Author: kddeisz (Kevin Deisz) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I rely on refinements a lot, but don't want to keep writing `Module.new` in code. I'm proposing `Object::refine`, which would create an anonymous module behind the scenes with equivalent functionality. So: ~~~ ruby class Test using Module.new { refine String do def refined? true end end } end ~~~ would become ~~~ ruby class Test refine String do def refined? true end end end ~~~ It's a small change, but reads a lot more clearly. Thoughts? -- https://bugs.ruby-lang.org/ Unsubscribe: