
Issue #19450 has been updated by nobu (Nobuyoshi Nakada). ioquatix (Samuel Williams) wrote in #note-4:
So, basically, given the above, I still prefer an interface like `Class.new(..., name: ...)`.
Although I'm fine with this interface,
The name I want to use is something like "Controller(path/to/file.rb)" or "Test(path/to/file.rb)" or something like that.
These names look tricky too. ---------------------------------------- Feature #19450: Is there an official way to set a class name without setting a constant? https://bugs.ruby-lang.org/issues/19450#change-101945 * Author: ioquatix (Samuel Williams) * Status: Open * Priority: Normal ---------------------------------------- This is the best I could come up with: ```ruby klass = Class.new Object.const_set("Klass", klass) Object.send(:remove_const, "Klass") puts klass.new # => #<Klass:0x0000000100a9d688> ``` Can we do better? What about something like: ```ruby Class.new(name: "Klass") ``` or ```ruby Class.new do def self.name "Klass" end end ``` etc -- https://bugs.ruby-lang.org/